{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "bdf4abf8",
   "metadata": {},
   "source": [
    "# 一、认识sympy的符号运算"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "e5cecce1",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAEAAAAAWCAYAAABwvpo0AAAC1klEQVR4nOXXW4hVZRQH8N/kPJUPgg9KlCIKKYj1ENhDghLeMUHxQcUUlSgM84JXVAZRFBSdSPFS4ohvEokWYQVZOtrDlDe8IUpigmKS+uK11Ie1T203+xz2cWYcGf9w+Dbru631P2v9v++rqaur8yLjpbZ2oAI6Yzp24zzu4BYaMU0L+V7bEou0EsZhE65gPy6hC8bgSwxPxjxqzibPIgOmCCcHVjnvHN7Ha5iIRZiK3vgTYwUZzUKWgB+Es9mFa9CQ9K1u7qYF8RO+wcOM/So2J98DM31zhY9zy6z5Bu7hQMmQJWBesuEKdEjZ12IyvsDCIt63Mh4k7T8Ze2PSvlNm3ucirk9KhiwBx7ETfTApsS3GHOzCR0/nb4uiFh8k3/syfUeEWPbPmTcOg7ERJ0rGPA1YgruoE0ytxPeCkGw6tgVWoy++E36l8QBNeB2vpuyvYB2uYVl6Qh4Bl1GP7iJlDgtNuF/AuYuiBtO/7Unf/py+hgJrpjFT1PdZ/2doFoeSNl0Gy4SYLhBH6X8odwz+lfqehtsFHaxHp4ztLYzGDkFQGscKrgsz8BlO4z38XWZciYD++FqcGrPxa+LDE8gjYLwQvavoik/xcUEn63NsUwQBDfi54DpZzMJ6nBTBX6sw9rDIrlIGbBDCN0POnSFbAiMES6fQT6TadMFiW2GBCP4YBqkcPNzAGbyNCYKwLTiaNzhNwLv4SmjAEFEGS0WWPKuzP4ulyd6/i0CuF5zXiJdF4NeFsOeiVAJv4lshEIPF9ZMg5DeRwgNwsCr3m4fJWI5/k31n5oy5KF9ID+FDdBT1X04v1KKXOE4eYSguZMYswo9Yo/wFozXQI2k7CA3Iwy/yCfgjaZuwrdImNe30ObwXI8Uf1lRp4PP8HH5aTMAo8ZKsGDzP93O4GnQTgfcU1+RTmF9kYnshYBhW4Sb2CM0odHlrLwRsTX5Voz1qQFV44Ql4DAXEnunZQW5TAAAAAElFTkSuQmCC\n",
      "text/latex": [
       "$\\displaystyle x + 2 y$"
      ],
      "text/plain": [
       "x + 2⋅y"
      ]
     },
     "execution_count": 1,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "from sympy import *\n",
    "init_printing()\n",
    "x,y=symbols('x y')\n",
    "\n",
    "expr=x+2*y\n",
    "expr"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "767d021a",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAGMAAAAWCAYAAADU1CLnAAADT0lEQVR4nO3YWYgcRRzH8c+afVIRwQdFPPDAA8TkQYiCQkTiiQdqHoxoFhNEiURjojGShEUUA4qORPHGFX0SUTwQD3A9NvFhPZJgVDxw1YAhLl6IV9T14d9DmqZ7tmd2pmd2yReaaqqqq3/Vv676V1Xf4OCgPfQGe3VbQAMOwBI8jy/xB37BCBbrbe1ZLsUGvItfMYGns5X6KxbVDAvwIL7HML7FgbgYj+GcpM5EtwQ2wRrMxm/YjuPyKlXxdw2IDzavyec+xwU4BJdjNa4SHfkOlwhjqmBAa32osxzHYD9cW1Qpa8bryUuznezDUFK2vkVBzfImXsJ/mfwdeCi5n5cpWyE0riho81j8hXfaI7E0w/jCJKM4a8ZNovO3Y1Yq/24swqO4pX0aW2ZXkv6TyR9J0pMLntsg+nVdJ0RNlawZW/AUjscVSd6tuBHP4JrqpBXSjyuT+1czZR+KQD8357kFmI8HsLVj6qZAXsxYgz8xKP6gO/CaMCc7ZXSD9TgBrwhdaXZhFIfi4FT+PrgHO7GuAo0tkWfGdtRwuBjWm0QM+btEe2NiXkxfTyRlwzllQ03qXSbiwWd2j9wsG5M0PVWtEwuBVWJ53IixHJ3t7EMhRUvbH1L3i/F7yfZq2D+TNwcX4knR0TSbS7YLS3EfPsEZ+LGgXt2MuXhOrL6W471Ew2TUdK4PDckz4zIRsHfgIFyvwXIsQy0nb0B0ZAhvNamvzg24Fx8LI3Y2qLtJ/LH1kXG/CNpLlduT1HLyBky9D5OSnabOFe5vw4liOliiYJNSEauEEZtxusZGwE/4FCdhoTDvYXzUOYntIW3GqXhWxIwzxVS1VoyeqvYWWdYm7/5AfNTxks+NYG9hwrhYlPQ89WlqNl4WwW2+OIIgzHlfDNHTxNlKVSzCbfg3ee+ynDpj8gPoRlyNfUW8KIovVXFRchFTP5xit/ZxrOzH0WKJOIGz8FWmodV4A3cp3kx1giOSdJaIGXm8Ld+Mr5N0FI+3VVVrzBE/V5ojkwu+wcq+GXqE/iLOEz/PaJe1lGY6HUOXZSHOFye+08YIevsIvRkOEyYcJY5KtuHmripqgZlixtm4Ez/jBRFjym5Ue4aZYsYjyTWtmYkxY9qyx4we4n8oBMEXwQheRgAAAABJRU5ErkJggg==\n",
      "text/latex": [
       "$\\displaystyle x + 2 y + 1$"
      ],
      "text/plain": [
       "x + 2⋅y + 1"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "expr+1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "05fde406",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAABsAAAAWCAYAAAAxSueLAAABzUlEQVR4nM3Vz4vNURjH8deYu8LOQgklCxaWiuVIigULms0UFmQzEk1Mielmw4pkNIjiD5AkYkO4Q7n5kfxKimxM0+THhjR+Lc65dXyd770z14986vQ8Pd/nnHfnPM/3nI5qtepfaUriz8BmnMMLfMIH1LCpkNuWKonfjSG8wTW8xkysxUmsijnf/wTsOdbgIr4l8d24g3URfLZdWHo0V3GhAIIRHIt+VxLvE3bZV7L2AnzGjRysmcaj/ZLEatEuLZlzBJ3YOhlYBRuifzmJ3xOaaElmTjdW4CgeTgZ2AItwCVeS+DjqmINZSXwaDmIUA+lCrWDbhJo8w/rM9+Fo06McwGz0C7/OhGC9OIwnWIa3TWCNo1yIHbiNM8XkMth2DOJRBI2U5N0SOrKxs0GhKXpl/sccrB+H8CCCRktA8A5PsRg9WI7juJ9LLsL2Cg1xN04cawJqqIapETKGPWWJ6Q2yEfvwFTeF5ijqFU4XYsPYgulCvXK1/QU2L9pOoWY5Xc/AXkZbx6kyED8fYxUdLUZXZo2dwhWXbYoyWDvqwWrhtai3Sq60SshoboTMF66xx9g1kYntwFZiP97jvFDfj38LdiKOSeu3n/r/FvYDdr9gtjfXCCAAAAAASUVORK5CYII=\n",
      "text/latex": [
       "$\\displaystyle 2 y$"
      ],
      "text/plain": [
       "2⋅y"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "expr-x"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "c045ff8e",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAFoAAAAXCAYAAACLbliwAAAEEElEQVR4nO3Za4hWRRgH8N/qfsg2KNAP0WUriiyIkgrsQ4WSlyi6UPghuygqXbBMk7KNlCWsFoq0i1RWZPWlwu1OZEFWrnYxa4tsJYokA22TyqC0rOzDc04ejud99313z7qt+IeXOfvMzH9m/jPzzDOzDa2trfaj/zGkJJ6n0Y2mkvgGK07DLkzPZ5Qh9Om4Am34rQS+/sJwzMCL+BrbsQ0dQpgytFiHl7AQB2UzyiC/C7/i4RK4+hOT8BhG40MsRjtOwuN4Hg0ltHM3DsWsrLGvQh+PcaKT2/vIVQumiq05phd1v8KFOAKXowXTcAI24VJcUkIfP8IGXIOhqTEv9JtiIPkGG7AsyWvL2Kclec9VaLRevv7E23gV/+TsW/BI8j0mlzdX9HFuBc6R+APv5ezPolksQuwp9M1JRxbKzAbuxRSx9W7N2Mfhb3xQoSP18g0UdibpXzl7R5KeUaHeg2Jc1+fsq5N0fGrIC/0ZnsGJuDKx3YabhHu4NlO2CaPQpfIhWA/fQKERVyXfb+TyPhEucXRBvUlCyCX4PJe3NknPTg1FPvp27ECrmKk7sUIIld12h4vZ3Fx1GLXzDRTaxIH4uuhXFjuFaEfisIy9CfeJkHZBAec2Mebm1FAk9PfiRD5KbI01wsf+mSs3PEl/7mEgtfLlsVH4x+zvySRvZUHesh74ijBL+N8Ndu+4PFI3kHUfC8ShOk+IWoSfMCL9o7FCoR8z39Pxe0GZNMo4oAJHvXx5LMYhOdsoXISnxERk0VkDZxYzcT++xDlCmCKkQo/GCyJKmYP3k35UwjCZSKxI6MvEYbVFxIM34rqCct1JOrwgrzd8eSwusE0VQi/DOzVwVMJsLMIXQuTuKmXXiB2TruiHhMucmdiLMEQskm+zhizOE7O0HieLLTVDzGIem8VKHVmlk/Xw7S3MEyJ3YqzqIhOusUvcgCeLiXkUn1apM1KEsJ2pISv0mVgufOoEIeJ8seqLYt1dIn4cgeMK8uvl2xuYn7S9Tgi2tcZ6HThQCLxVHPDVkK7+lakhdR2n4DXh2MfbHUksx8diu56FVTnCdnGjmijeD1L0lq8/MQV3iLh/ldwVOcFGxYfqalwt3i/mqOzPU0xI2nk5NTSK1bhCrNCJ+CZXqQVv4R57Bu7t+EHEoUsSW1/4+hPHJOlQ4aOL8K5ioVNfuxZP9NDOwbhYLLRNqbGhhPfoFvGwdKrqfmsw4xWcLxbG2h7K3oAHxGXlvx1bxuvdInwntuW+iMm4QLxO9iTyMLHw2uXcYqU4uh7sEMH+WHFj+j+/SdeKZiHwscItrsctNdQ7GksVuJ8yhCaij/wL1mDGueJd+RdxoM1W2yWrSzw17IGyhN7XsDT5lYay/me4Hz1gv9B7Cf8CmDAGw8jHqMwAAAAASUVORK5CYII=\n",
      "text/latex": [
       "$\\displaystyle x \\left(x + 2 y\\right)$"
      ],
      "text/plain": [
       "x⋅(x + 2⋅y)"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "x*(expr)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "94ac4bf5",
   "metadata": {},
   "source": [
    "sympy只会进行显而易见的化简，而在x(x+2y)中，或许因式分解更有用，或者展开，sympy给我们自己做主，如果想将上式展开："
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "e3b95fc2",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAFYAAAAaCAYAAAAtzKvgAAADgElEQVR4nO3ZWYhcRRQG4G/MPLmA6IMiLoiCCqI+CBE3RkNcUUHJQ+KSkARRImqMGiMmNKIYcBu3uOOIbyKKC6KJGjWTKIzLKEZFFIMKhiS4PbglGh/Obb0Wt+/MndvT48T+oajbtZyq81fVOaeqexqNhi7aj51q9l+CIfyEzXgeh9ed1I6AusT2YQWOxcnYhlewR025kx69Nfufmvy+ED/iOLF7/7eou2NT7JbJ/K7NckfCnpiPZ/A5fhELPIh52q/niKi7Y1P0Yxhvt1nuSJiB+/EtVuMr7IVz8QhOz9ps79SE2rmSt+JEocAfY+g/RyjeN4a+n+Fs7IvzhVOdi0PxNc4TJHcMKbErhXLpJHowkNUtL5BzOy7CNHEUO43XhE3/MynfiAey776kroqui7Lfi1qMfwh+w5vNgpTYa7LJ3YQpufLbMBsP47qkz924ACfh4xYDTyS2Zvm2pLyKroNZfkyLMe7JZFzWLEiJ/QBP4DDh4eF6XIUncUnSfoU4wjOFw9o7S7u2mECn0StOEryU1FXR9T3hEKcWjDED03EfPmwWFtnYG/ArGmIFbsbL2eDpUbtURAKvCsfRTFcXyJ0ILBcXlheFDilGq+tWcRHaD/vkynfBHdiEZXnBRcR+I7z7AWKLrxN26PeCtj0tUqNIyxw2CJuVT49ldasL6gZGkFeEy4VN/NQ/OzJFFV3XZnneHCwTDnOxCO/+Rqtwa3Puex5+bjX7MaIfuydlR+EcPC6Iz2O4ovwFuEvY/GnK4+rR6tokdiqeFhHHQrwl5vwvFBE7UxjwjcJeXiGOfDvRX1A2RxA7gNdryL4Sd+IjQeqmkrZVdF0nTk9zx94rHNYCBfFxagrOEOyvxxHiGM0XqzMZsFiQOiyilDJSq+r6PT7B0ZglFu1BvF/UOE/s8XhK2J1TxBFZKnZ1Uez6X8NSMc93hdJbStqOVddB7CwI3SKcXyGapuBIvCAM8HTh2WWDvyOO6AlYUzLoRGI2bhQ3vjXCcaXYIMxMHV3X4mIRTi5UYrt7cbAIMbaL16ovkjZLsEpcWVsFyBONA7N8irCxRXhD7Lg6un6Z5UN4tGxCPd1/ECrhOZwpSB8qa9jx57RJjFk4S7yilZJK+58NdzTsLwg9SFyN1+Pa0XTsEluO03ALfsCzwn6P6rLUJbYcD2WpMro2dpzQJXac0CV2nPAXICDlp2I5mRcAAAAASUVORK5CYII=\n",
      "text/latex": [
       "$\\displaystyle x^{2} + 2 x y$"
      ],
      "text/plain": [
       " 2        \n",
       "x  + 2⋅x⋅y"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "expanded_expr=expand(x*expr)\n",
    "\n",
    "expanded_expr"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "f89cbb21",
   "metadata": {},
   "source": [
    "又或者想提取因式："
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "de83036e",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAFoAAAAXCAYAAACLbliwAAAEEElEQVR4nO3Za4hWRRgH8N/qfsg2KNAP0WUriiyIkgrsQ4WSlyi6UPghuygqXbBMk7KNlCWsFoq0i1RWZPWlwu1OZEFWrnYxa4tsJYokA22TyqC0rOzDc04ejud99313z7qt+IeXOfvMzH9m/jPzzDOzDa2trfaj/zGkJJ6n0Y2mkvgGK07DLkzPZ5Qh9Om4Am34rQS+/sJwzMCL+BrbsQ0dQpgytFiHl7AQB2UzyiC/C7/i4RK4+hOT8BhG40MsRjtOwuN4Hg0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mDGueJd+RdxoM1W2yWrSzw17IGyhN7XsDT5lYay/me4Hz1gv9B7Cf8CmDAGw8jHqMwAAAAASUVORK5CYII=\n",
      "text/latex": [
       "$\\displaystyle x \\left(x + 2 y\\right)$"
      ],
      "text/plain": [
       "x⋅(x + 2⋅y)"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "factor(expanded_expr)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "2dbeb6df",
   "metadata": {},
   "source": [
    "----"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "5c8e9c89",
   "metadata": {},
   "source": [
    "# 二、更有力量的符号运算"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "42a655b7",
   "metadata": {},
   "outputs": [],
   "source": [
    "from sympy import *"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "a0bc4f6b",
   "metadata": {},
   "outputs": [],
   "source": [
    "x,t,z,nu=symbols('x t z nu')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "id": "721d20e3",
   "metadata": {},
   "outputs": [],
   "source": [
    "init_printing(use_unicode=True)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "5aa08889",
   "metadata": {},
   "source": [
    "## 1、求导（diff）"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "id": "82dfab83",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAE8AAAAWCAYAAACBtcG5AAAEO0lEQVR4nO3Ya4hVVRQH8N+ogWJQqNUHQeeDZIk1YS8LjRIzqagokoJMzMqQrIgkFYMpLA3tYUFBUaRRWTnR9LAUo7R3GplhBhWUWpaKaVA+MqcP6xw9c+bcud45E4j4h8u+Z529/3vvtddrn7rGxkZH0DF0KTn+auxG/4xsHr7HcTVy1aMFz5VcUxYLsBk9S3CcLtY1If+irPIW4RvMSJ7vwjUYjS0lucviDFyH2firBM+XeB0zcXT2Rb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nAK+Y3CFUPyGVFh3GH/PmyYu8UNEAV8Gk/GYSHL7rbIzPgwcqnhElFX3leTpIQ6iSc6dD2fl7RJhZ5VyH0Pr8ZT4VtkKZb/nHepYkfzKYJ3iG9dhbXn/O44orwT+A//P8nq3Fzd7AAAAAElFTkSuQmCC\n",
      "text/latex": [
       "$\\displaystyle e^{x} \\sin{\\left(x \\right)}$"
      ],
      "text/plain": [
       " x       \n",
       "ℯ ⋅sin(x)"
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "e1=exp(x)*sin(x)\n",
    "e1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "id": "ac204809",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAALsAAAAWCAYAAACYEu1aAAAGUklEQVR4nO3bf4wdVRUH8M+2EGkgaUMRMRBYk0akqZYAKpqqlSCiMfyMjSQgv3/YCBq1QpuSrFoLWtDiL4wEwo+AVVmwikCbKhYVUTDUHwUjGhBaq0Bwi8GCVOof5052dnbe2zf73oxNed+kuW/v3Dlz5n7PPefcc6cDQ0ND+ujjlYApXd7/QbyIg3J9V+FRvLqirEHswPVd6pTHjXgKe3Yh43Ch19k90agZ9JKXJlErX90a+634PZamvz+FD+FYPN2l7G5xBE7F5Xi+Czm/wfexDHt1r1Yj2Jl5aYXa+dqtC6HEClqCH+Ev6fdR6XdVbMYh2NqlThmW4zlc3QNZl+FXuCjJ3dnRS16aQu18devZYS0eECtpAR6cpJyX8Eds6YFOr8fR+C629UDer4Vu52PqJGWcIYxwfg/06QS94qUJNMJXK2M/GXfhGfxH5HpLlBN9FOYmWU+1kHccfiwM+UX8DeuxMDdmUHnOnu8fxKqk1wuCwA+UPO8sDOA7LfRZm2SeVOgfSM/ZIcJpHqtwoCDl/4Ve8wJvEfO0WXCzRczPgpKxC3CviL7bRKq0GK8qGdsJ5xka4ato7FPxbZHzzcL38A28jM/jusL4ubgt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WqSAlyb5ReSrMVlpc6mx39ZMFd52Cq7N9VfhvDG+8gotEjXWYawTkzxFhLnDRR11MpWIVWJX/HORqw6Ilf1m8R3DuknInAjD4gDmvfhzrn+uqFRsFfXXLAe9VeSRxxtfostwjNggr65B33aoi5eHRU79TeG5V4tDqpniO5V/GT2/uA9fxKfxBzFfz4uoMEdwuyInuyrnjfCV39itFbnVMN4oNhanifxqnWoHQHlcgl+KHf3CJGd3XCwms6w81S2G8Q9Rf84wS+SLO8SkFnPPxaldYTymi4OXO0T1p0nUxQtxGDNPvNd8sbCOE5vLrxfGXizy5kfFvF4k7GepMMR8VaQq543wNbALf8++WBxyHGY055wsLsRXxAFFmRfpo3vUzlcvPgTbWfFlUY77bJdypgkihvUNvU7UzteubOwviHD/oO7+M8AgviW+Ce+jPtTO166cxvTRxxjsyp69jz7GoG/sfbxi8D860Re5u0aWEwAAAABJRU5ErkJggg==\n",
      "text/latex": [
       "$\\displaystyle e^{x} \\sin{\\left(x \\right)} + e^{x} \\cos{\\left(x \\right)}$"
      ],
      "text/plain": [
       " x           x       \n",
       "ℯ ⋅sin(x) + ℯ ⋅cos(x)"
      ]
     },
     "execution_count": 11,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "diff(e1,x)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "f8cc694c",
   "metadata": {},
   "source": [
    "## 2、不定积分（integrate）"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "id": "91629ce2",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAALsAAAAWCAYAAACYEu1aAAAGUklEQVR4nO3bf4wdVRUH8M+2EGkgaUMRMRBYk0akqZYAKpqqlSCiMfyMjSQgv3/YCBq1QpuSrFoLWtDiL4wEwo+AVVmwikCbKhYVUTDUHwUjGhBaq0Bwi8GCVOof5052dnbe2zf73oxNed+kuW/v3Dlz5n7PPefcc6cDQ0ND+ujjlYApXd7/QbyIg3J9V+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q3mhKAV9XGwo1ovQ12mVYKRF/3ZjI1S2m9+jA5n5yT9bGFQ7TNNZtWClID6PQ3G8MOzHC9c2tJFVFy8zUru5g7HTU9vK+24RHnS64KkK543xlRn7HuJk7V68q4OHVsWN6d8MvB0nitC4RniidtWCqshkzWw7KoznChGW98PHRGhvhSlC/8c60GFlSd8ZwtivF3l2J6iTl5HU7i/KdO2QnX3sp7xW/9rCODrnvDG+Mo84kNoqG8bJYERsns4VpO8tNke9xBbhAQ5uM+b9wsNuxJsE2efgDW3uOVjM04aeaNkZ6uQlq3y8r4OxD6V2fsm1WWIz+5jy6DuiPeeN8ZUZ+zaxkZltfC0zwzyTO1A5VvlJ7b6pnSgUVcUO4Qn3EUQUMU9s2DaJFOFpUeHYzfhabR5ZjluWc9eFOnm5WqSAlyb5ReSrMVlpc6mx39ZMFd52Cq7N9VfhvDG+8gotEjXWYawTkzxFhLnDRR11MpWIVWJX/HORqw6Ilf1m8R3DuknInAjD4gDmvfhzrn+uqFRsFfXXLAe9VeSRxxtfostwjNggr65B33aoi5eHRU79TeG5V4tDqpniO5V/GT2/uA9fxKfxBzFfz4uoMEdwuyInuyrnjfCV39itFbnVMN4oNhanifxqnWoHQHlcgl+KHf3CJGd3XCwms6w81S2G8Q9Rf84wS+SLO8SkFnPPxaldYTymi4OXO0T1p0nUxQtxGDNPvNd8sbCOE5vLrxfGXizy5kfFvF4k7GepMMR8VaQq543wNbALf8++WBxyHGY055wsLsRXxAFFmRfpo3vUzlcvPgTbWfFlUY77bJdypgkihvUNvU7UzteubOwviHD/oO7+M8AgviW+Ce+jPtTO166cxvTRxxjsyp69jz7GoG/sfbxi8D860Re5u0aWEwAAAABJRU5ErkJggg==\n",
      "text/latex": [
       "$\\displaystyle e^{x} \\sin{\\left(x \\right)} + e^{x} \\cos{\\left(x \\right)}$"
      ],
      "text/plain": [
       " x           x       \n",
       "ℯ ⋅sin(x) + ℯ ⋅cos(x)"
      ]
     },
     "execution_count": 12,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "e2=exp(x)*sin(x)+exp(x)*cos(x)\n",
    "e2"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "3ec83a68",
   "metadata": {},
   "source": [
    "* 原函数形式"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "id": "4356f6b6",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAE8AAAAWCAYAAACBtcG5AAAEO0lEQVR4nO3Ya4hVVRQH8N+ogWJQqNUHQeeDZIk1YS8LjRIzqagokoJMzMqQrIgkFYMpLA3tYUFBUaRRWTnR9LAUo7R3GplhBhWUWpaKaVA+MqcP6xw9c+bcud45E4j4h8u+Z529/3vvtddrn7rGxkZH0DF0KTn+auxG/4xsHr7HcTVy1aMFz5VcUxYLsBk9S3CcLtY1If+irPIW4RvMSJ7vwjUYjS0lucviDFyH2firBM+XeB0zcXT2RbcSpMSJTMfb+DH5PyL5Xyt+wcnYUXJNKR7An3iyE7hm4XPclvCivOXBUqwUJzMGqzrI8w++w6ZOWNOJGIlXsLMT+L4Qa5uIrqmwkvKuwjvYij0ihk3PDsxgBBoSrs0V+C7De0Ixu/ErlmNSpk+94piXlddjYbKuXeKgLi2Y7wbU4eUK61macF6Zk9cl87QId89iIfqJQ0Fb5XXFSyKWDcCreAL7cD+ezfVvwGtCCW8kffK4Gc0YhDfxEBajB8ZX2FwR+gsLqMfzQjGDE+4Lcn1H4l98VoFritjTTK0NYi7G4WlMzY35OGkvTAX5mDdPBPzZuAd7M5N9gOvxIL5NNrMYczAfX2E1huPDDOdEYb0N2lpmnwqbK8L5aMS9GdmLeDdZ3/uJrCdOwzqVE8XX4gDGYaywtum4U7j6LQVjVibteakga3lnCwtqxjQHFEfEo/mZfr2SRb/lgLWtERY7q2DivQlHHlsLZJXws7CULJZgPc7KyPoKa6oWO2cI12/ErWIfS4Qy9xX035H075cKspY3Wfj83wlhHoOTtg7bRGbMY0yB7AXhqmuFqy0XLlBrKbNauGIeG3BO5rl30v5RhW8jHhXu+Tg+ETFwTztjtuGE9CGrvFFJe22VSddXeZ/Hw8LCJolUf4cIyMuFux1sdt5eQb5Xaw9Ks2v3g+DMHuAEYTjtoUeGf/+k3cWNYIWwrPZ+yw5iUXkswFBhFZfgGRE7luD4DvC1hzSu9m63VxjJXPyWPN9epX8XHJvh36+8uqStJYB3BNtFkrlJBOleIsF0JjYJixrYTp+LRQxfi1NFDXcjTmpnzEChp9WpIFXeThHwB2lb+6QYprjOq4bRim8yqcVVc5Va0SI8qI8ot/IYJhLbRhGqtojKopu2tV0WQ5M2zeqtNjVFXLOahGuuEcrtKy7HR8lkmhqwUGSpj/CTOL3hOFPcGzsSBqqhSRT6F+GHjLxBVAg7RL2WZuRFIvZerm2plWKUSFjNqSAbaJfi3GTiU0RwHyuy6jK1FbRZTMWnGCKSxnhxEHeL4raohCmLJvwu6tIUA0SMbRFKzd+/pyXtnAK+Y3CFUPyGVFh3GH/PmyYu8UNEAV8Gk/GYSHL7rbIzPgwcqnhElFX3leTpIQ6iSc6dD2fl7RJhZ5VyH0Pr8ZT4VtkKZb/nHepYkfzKYJ3iG9dhbXn/O44orwT+A//P8nq3Fzd7AAAAAElFTkSuQmCC\n",
      "text/latex": [
       "$\\displaystyle e^{x} \\sin{\\left(x \\right)}$"
      ],
      "text/plain": [
       " x       \n",
       "ℯ ⋅sin(x)"
      ]
     },
     "execution_count": 13,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "integrate(e2,x)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "e8f582fc",
   "metadata": {},
   "source": [
    "* 积分形式"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "id": "cb6eb77a",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAPcAAAAgCAYAAADOt+7EAAAI6klEQVR4nO2df5CXRR3HXweah+bACJpFyskwGQx5DhiVUWFDaGVSVjc6heBPk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yvh11FptBbVlPdoXzUCdaymyM31empDsT7P2zGVSpjY3oG3NUlN/Gjtanhy1LaH6F0+GIg81BPi+9dxX9zK0Ardervz96A7BaOBTqbzLqZyPp4Nphe2ttSw/3Pradc7diS5BnAr8LZXXjs43O4G7UYcagho3GZ1h1hMpXoeihvehvWYTmrXfi17M3XXU6UNeW1vRMdEedMSR7CHXo33gTGPfb1P1zUAz+YaS7K1FWdr8Ee2Jb0SeeQPq0CPRXe+XqNwh2IL+dNdlwBPofb2MvP5EpO8qq+4iuofWCtx6+ei5EnngTtOeXWjl8h4UyD2Gas9dl721PLd9+d11Q60TBQDOycjbhPYRncb4BShsPx4JUeTCic1C4AEUbZ1n6jkYzX6nkH1UEoKsto5D+71e1JHSe8fkXvuq1PPh6JLHHUjU/qYsbUAXKqaitk1DE8kZKBh2Xars5Wgv+SR6rwtQ31yCOrMdCS6ie0itwK2Xr55rUSBwO2r3bFP+g8auF9ERbUP2NtX408atVPYNY3EHfBahiwaTqOyjDlRCtXU+8B104SHLS0QaJ2S/dOk1oPSsNbinUjHwSNwXQ5qBv6ClXXovcaARoq3D0Cy8BfhcILsifQnVL116DTg97WX5FBR5vN58f4xJe3BfBADtg2ahPUCjf6xhoBOirS3oDvGlgWyKZBOqX7ZQWy9Xfr9je+6xaObZh9b+y1Ho/SEUrIhEIoMIO1r+DxQIOJ3qSN2V/WpRJBIJQjpaPgvd3d2LfgNlJgq3RyKRQUb6nLub6v9dJBKJDFKK/EeAkUhkEBEHdyRygPJ/GOXigMUuS7UAAAAASUVORK5CYII=\n",
      "text/latex": [
       "$\\displaystyle \\int \\left(e^{x} \\sin{\\left(x \\right)} + e^{x} \\cos{\\left(x \\right)}\\right)\\, dx$"
      ],
      "text/plain": [
       "⌠                           \n",
       "⎮ ⎛ x           x       ⎞   \n",
       "⎮ ⎝ℯ ⋅sin(x) + ℯ ⋅cos(x)⎠ dx\n",
       "⌡                           "
      ]
     },
     "execution_count": 14,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    " Integral(e2,x)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "67fd39c4",
   "metadata": {},
   "source": [
    "## 3、不定积分（integrate）修改定积分参数"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "id": "18b7f420",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAEMAAAAYCAYAAAChg0BHAAADxElEQVR4nO3Ya4hVVRQH8N9oQZNFpRkDgc4HyQrJHhZSKWOpRUVF0YcgR8zKiiiIIouCW/QCm+wBFkVkRjGFQ0kSGUZkT9Joood9KDB7WClm0cOmqenDOqf2nLln7m3mokP4h8258z97r7322ut1pqlSqdiDwKjdrUCDcSPW4ydsxQuYUu/i/5sx2rAMJ+IU9GItxtazeCjGaEUflg9hbRlW4HuMGaac0/A4PsKHmIfxOCmZc5zQf2Fx8UjwjGm4CHfjlwbL3l+ccXvCvYfncTv2SycPxRhf4wgRn43AnSLGH2qQvBT3oRvvFPi70IKrU3IoxvgDn2LLENYWcRhm41n81gB5KZZgJi7An4V374ozLMLonCwa42y8Ig76O77Ba7gymdNqYM5IuVZ0Yht2YgPOKlH4YjThmZL3L2dyzyvwTdlefSK8iuhAO07FZyWyOzFBXAb6G+MyrMKRoiR14EU0Y0GJwCImCqu34klxyCmZ3FlV5s8Wt1Z04xzX4y8R36MT/h7Mx6NYXFjzgMhBs/DJILq+mT3n5MReyctF6MFUkdlTHDyI0BRtqODWhHsaL4mDvZrwY3A0NipPnB8Io84XlWE5bsK1IrQuL8xfJgxxrkiaLRn/czZSrM+eM3OiGCa9IicUsa1E2SK+ELeYYg0244QCf6i47Vq552YRbhVchTsymfOE16S4QlSQPNTzcV0VuT9mcifkRGqMp7AvPsZSYd3xNRQtotvAZAVf4qACNy57/lBD5leiKkzEg3hL5JCeKnObSkalRPZ2idenxrhXuONmUXKew3fCtafVUDjHjhK+10AvzKvHPnXI3Zr8Xohf69SnFpoTPQYouALTxa2dicdETK3BIQ1SIEeel8YNOosLRcL8Nvv7mgbtPwoHJnqU9hk7RCW5VCStsZjRICVybBE3PnmQOWfgCRG6R4ne4BIc3oD9J4sQ6s6J1Bin619dcuQe0SjXzNGHdSJmJ1V5fzJWipwxVxjulkzHar3Ff8X07PlPhUsP3ymy6xvYJKw2A8eLfn5tAxQoogvniw+stDmaitUi48/xb8VZKZq4czLdXh/G3nNFsl+VE6lnLMbbOFZ0nAuwN24QDUy1kjtcdIkk3Z5wk0SO6hNG+rywJv8mWjKMfQ8Q1XK1qHTo7xkPZ6MWNgmvqcWlaCvhe3C/+Fg7Bu8LD2kpmU946GB71YN2UcU6UnIkfMIvFeX8tl20X7Pwri6FMBsJxtgpuskNhv/PnXrQikdU6UqrVY/dgXXZ2BXYqKQjHQmeMWKwxxgJ/gbNBMz8/qvsxAAAAABJRU5ErkJggg==\n",
      "text/latex": [
       "$\\displaystyle \\sin{\\left(x^{2} \\right)}$"
      ],
      "text/plain": [
       "   ⎛ 2⎞\n",
       "sin⎝x ⎠"
      ]
     },
     "execution_count": 15,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "e3=sin(x**2)\n",
    "e3"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "id": "5ae99e05",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAE4AAAAdCAYAAAAEsFpEAAAD9ElEQVR4nO3ZfYhmUxzA8c/sLHlZZDcpSRHLZstji1qFHWos62V3tKTY+YPapLQSorYmIXlJpPiDQivaMAZjSO02iMhu4zU2RZJd8jZrveza2fXH7z7t7c69z3PvM8+MnZpv3c4z595zzu/3u7+Xc+Z29PX1maE6s/5vAaYrsys+fxi2t3H9jjbONaVU9bgLsFQo3I5r2lLVcEuwcRLkmHZUMVxncu2aJFmmFVUMdxbemyxBphtVDHcRXp8sQQpYip14DXvbeE2YKoabh1/asWgFVuEmXKx9BaktRams4U7CVzn983Ad+vE1/sYo3sW1Feb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le \\frac{\\sqrt{2} \\sqrt{\\pi}}{2}$"
      ],
      "text/plain": [
       "√2⋅√π\n",
       "─────\n",
       "  2  "
      ]
     },
     "execution_count": 16,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "integrate(e3,(x,-oo,oo))"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "c70ffdc0",
   "metadata": {},
   "source": [
    "## 4、极限（limit）"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "id": "5240a41a",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAE0AAAAVCAYAAAAD1GMqAAAD1klEQVR4nO3YW4hWVRQH8N9ohZOClVZCYfMgmRHZRcOHFA2dJCsde4ggFbMyeigIIouCKbpBmV0eiiIoo5jCyUS7WJZ0jy5kD2EPRWYXs6wsqGyypod1htmdOef7/M43xQT9YdjfrLP2+q+z9l5r7X1aOjs7/Y/GMKzCnDb04qFB9GM1vsHIJmycLPxaNige1UCVoA02puB83Iqfm7DzHp7CjRhVR/dw/IG7qxBVCdqXmISrqxAW4Gb8hHsHwdYtGIfL6ujNF+++tgpJlaD9jo+wowphDkdjNp7Ar4Ng723h23IMr6HXge/wShWSfNDOxosiIL/hK7yMSxOdNgNrWiprQxd2YQ/exZkl/BegBY+XPH8+s7swJ2/JuHpFWqfownixGEUYjdOwXqRowzxp0C7GOhybGVyJZ9CKpSUO5HGUWO02PCKCcVxmd1aB/uzM8bdK7F2JP0WdSnfO7ViCB7AiN+f1bJxTYnMeDsCTVXn2SxSWoweTRSdLMbbEgTxmohPXJ7LH8Fzm2OZEPhInYKvyBvCBCP4SLBKrfg2uECl9ScGcd7JxRonNjozvhao8adBgr6hZeewqcSCPz8RqpdiI7TglJz9CrGq92ngtzhWLMQo3ZTYXid2Rx4+iLIwveDYCc/FsplOJJ03PR3EgPsQqLMChdV4ojy3660SKz3FwTjYmG3+oY/ML3ClS/x68IWpPT4053yvOjnYRkKKuuc88adDuENtzu2jZa7FTpNSUGg6m2F0i32tg0+nrliP2we63ye9l+KWOfqvibtwhgvB0Mzz5F1mNaWIXzMODojZsxGF1HG0UfXVzTE0tzhMF+evs/8vr6A/DQQbW5eE4Cy+JFK7MU3ZO2y0650WiKB6C6XWcbRQ7xMpOrKFzBh4WJeN4cQa7EMfUmDNRHBW25OQzxAIVpWZDPGnQ5hrYGOjfYfVSolH0isPlWEwoeH4q1oha0y4CfF3mY/5slmJaNm7OyReKgr6uWZ40SF2io7yGbWK1pmOquNdtquFoVXTjHJyOjxP5ZGwQaTRHf4ddIw7L8zPfXi2w2S6aUT44C0Rx39ksT7rTVuBNnCRuAEuxP64SB9Oio0iz6BYvsTiRTRA1tFcE85PcnL47720F9kaL4GwQHbsPU3Gkv6dmZZ50p92X/dXDNrEL68lSzCyR9+AucWk/Ee+LHTeuhq1NNbgWi268MifvyMY0aJV5hsKnoVXimHNDk3Zaxe7oNjBtO8Sp/9MmOVBc+P9t7BGn7lnialX1m1ob7lf8cXRSRZuFGApBI7popc80CbaKK9A/jqGQnv85/AVP7/YlnBSSkgAAAABJRU5ErkJggg==\n",
      "text/latex": [
       "$\\displaystyle \\frac{\\sin{\\left(x \\right)}}{x}$"
      ],
      "text/plain": [
       "sin(x)\n",
       "──────\n",
       "  x   "
      ]
     },
     "execution_count": 17,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "e4=sin(x)/x\n",
    "e4"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "id": "6ef823aa",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAA0AAAASCAYAAACAa1QyAAAAh0lEQVR4nO3RIQ7CYAwF4G8EPY0kCIIbllsg8NNIkknEfwcugOAeCE5CgkQR/GZ+1WTLMFM0eWlf05fXtEVKya8xC/yACx74oMUtiuaBn1Hhixc2Y5xOWKPEsW+96HTvGxxyGhV/0eSi+Nx9Bixy3uGa6zeaKNqiDr1VBjzRxPUSigEsmfIQHbJ7ECMDdcssAAAAAElFTkSuQmCC\n",
      "text/latex": [
       "$\\displaystyle 1$"
      ],
      "text/plain": [
       "1"
      ]
     },
     "execution_count": 18,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "limit(e4,x,0)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "6f2abd84",
   "metadata": {},
   "source": [
    "## 5、解方程（solve）"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "id": "3da4f99f",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAD0AAAAWCAYAAABzCZQcAAACXklEQVR4nO3YW4hNYRQH8N+YeeSFB96kPFDiVW5hQjxQIw/KrcYDEXKJkamTqCnkVkPxQDyJPLjkLo0kl6KQRE0SE1I8IJcZD2ufjO2MGfY+mpr519feZ531rb3W9/2//17nVBQKBT0NfTLOr8NtfMAbnMKIrEmVG1mLnohGjMFkfMMl9M8Yt6yoyjh/WurzfLzHWLHr3RJZdzqNfknMdznH7QwDsBgn8RSfxOJfR61UnVl3Oo1duIebOcftDHOwD69wFc8xEDU4iOmJTxv5Fr0NEzAe33OM2xU8wUycQWs7+0bcwmyxACf4nd4XxGrUpOwVOJR811DioTuwANWCXv8bV4SGtKbsLdif3E8sGtNFr0smbkFlO/t2LMQBbEjN2YN5mIRH/5532fA1uX4rGtJF38cRDBdKTFBkNY5hScq/EYswV4jXoGT0zTHpLKgSDIRzRWMp9d6EzyhgObbivFiENH2WCsW+LESkONbml3cmNIhm6ayoAaWLfiFUeDD24oY4419K+FZ0MAqdJNMs9KGr42gn8UphBdbgsZ+sRcfq/abdfS0+/sND/4Rngk1dxcu/jL8Mu4XGVEv1DaWKniuEq0Wcz5WCxnmiOud47bEKO/Egec7rtEOa3jNwGA8xUlBjMYaVMck8sV4UfE+8TX4rmF+LHofj4kxPFRSvF2wo9W7ubqgXed4VO/y2I8civUfhtOhXpwgFJhbhDmaJTqupPPlmxkJsFp1gkxCxNJpFg6UKQ4Wct4lfTc9SznW4KNrM0WVIOA8MSa6V4kyXwjVJ0RW9/5z0EPQW3VPwA6fHh+hsGuSeAAAAAElFTkSuQmCC\n",
      "text/latex": [
       "$\\displaystyle x^{2} - 2$"
      ],
      "text/plain": [
       " 2    \n",
       "x  - 2"
      ]
     },
     "execution_count": 19,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "e5=x**2-2\n",
    "e5"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "id": "e6f3bdaa",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAGkAAAAdCAYAAACpMULtAAAC9UlEQVR4nO3aS4jVVhjA8d/4AEGEoogLcdGFgmAFV1ZRuCK0VUFB6ULFKuhOEUGkIAijuFAKrV3pwoULcSeiorYuLIOiIBQGLEXFiojYIj6olmrrc3EycGdMZpKYe5LB+UO4d5Lz+CffyZdzcqeru7vbCM1mTMq+7zAXt3Ed+6IafdxswgJMxQOsJT1I03AfG2KZJUzA5zhfYZtdFbaVxQQ8rbjN/Wj1/TGq4sY/hC8Fn64Kt1jeX3XSu0lBauGXuiVK0NJh76YEaXSy/V+3SEGieDclSPNxuW6JEkTxbkqQluJs3RIliOLdlCBNwqO6JUoQxbsJQZqOGxnHJglrhxO4hef4G5ewUb3+0bzT1kmxWY7TGce+xkH8Kcyg7mIKVuIwliRl3nZe8z2ieTchSDNwM+PYTeFinMGbtv07cRWrhBM/3knBDKJ5x0oXo7BXGEHtTDR4Tr8gjNY3A/b/hUPJ91YFflk0wjtWkL7APOEWb+dDZkcvk89XZaVy0AjvWOnuJ2EUnRcGRt8Im4djJdobg2/a2u4UjfCOOTvqxb/CAhDG4rX3U0Ie9mGWMJp/rkJuEHrV7F0kSHeE2Uje7WhKG6ewIvneQk+B/vvYiu3CzyjrStQvQ63eRdLdH3hRoPz9lH0nhanpDiHf7y7QHmzGj/gdi/G4YP2y1OpdJEiLizScQQ8mYybG458CdbfhB/yWuDyowCcvtXrHXrG/EvLxLlwrUO9b4UR7sUjcAFGzdx2vVU5itezV+kB2CQ/cX4WR+LBAX0eE5+OGAnWyiOndjzreOJzDFdzLUXY99gizqYvCw3cgd4RgpNE3CKtYS8X07kcdQXqGZTnLfpp8jhZyexo9sk/2s6S/Mzn7G4yY3v3ISndzcABbckoV5UnOct2G/n+AVkbdTzBbeA2Tt7+h6LT3GuG695ukpd1J64UFG+F2Ha4sFF7BfF+3SAGOC2sy2q59WpD+S7bhzmmMq1uiIKnXvgk/+o0wBCNBGgaMBGkY8A6Q+tShEmu3ZwAAAABJRU5ErkJggg==\n",
      "text/latex": [
       "$\\displaystyle \\left[ - \\sqrt{2}, \\  \\sqrt{2}\\right]$"
      ],
      "text/plain": [
       "[-√2, √2]"
      ]
     },
     "execution_count": 20,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "solve(e5,x)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "feaa86ba",
   "metadata": {},
   "source": [
    "**更多功能待补充**"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "5882b126",
   "metadata": {},
   "source": [
    "# 三、陷阱"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "580c7715",
   "metadata": {},
   "source": [
    "## 1、符号的陷阱"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "de7fadd8",
   "metadata": {},
   "source": [
    "标准错误"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "45f122a6",
   "metadata": {},
   "source": [
    "![20210614-221924-0038.png](https://gitee.com/tsldsd/pictures/raw/master/img/20210614-221924-0038.png)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "310b649b",
   "metadata": {},
   "source": [
    "* 定义一个Sympy变量"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "id": "f6eae4a7",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAADMAAAAWCAYAAABtwKSvAAAB20lEQVR4nN3Xu2sVQRjG4SfhiIJBgzZiIWIh4oUExUIrLSzEIhZprIwIgiCKIIJgcf4CCaYSBE/wUgpaCNpEUBBtvDWCjbdSBcXCxksxc8iw7FnX3XNJ8oPhg5lvZ993d+ab3aFms2mpMDxoASWYxAwe4Tv+4EZeYqOPoqpyEWP4gU/Y0imxH29mSnia+ypefxabsQonixKzZvbGG1/GEeHVfsNPPMP+ioLqMIe3UVchWTM7YzyA6/iKK4Kp3biHDV2T2WU6mVkvLIsJnBfMzWAFTvdL3P/SycwpPM6MXY1xa08V1SA1s1wQ+hE3c3K/xLisYL53wtpO27U4Npcz1qomO5+0NO+IQu/jd07uxhg/FMw3jdFM37iwXGcFsykvSmgsTWqmvcSyN2xzKMYHBfNN5/RNCWZaeFhWWBXSZdY2M5qTtwYnhEPrTi8F1SE1syvGSaxM+kdwC2txRjhzFiSNJG7HS6zGK9wVisKEUKov4PYANB6ODdbFuMd88fiMc8yb2SacIU9wSfgCOI4hPMUxxXull4zjaKZvU2zwXsZMe788Fz4dDnZRTEu9EtyM7Z+090xqZtGSmvmF1wPUUpvh2MbwxgKuVGVoCKf9yKCFdIPF8NtcmiVl5i/85FKxduKfIwAAAABJRU5ErkJggg==\n",
      "text/latex": [
       "$\\displaystyle p + 1$"
      ],
      "text/plain": [
       "p + 1"
      ]
     },
     "execution_count": 21,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "p=symbols('p')\n",
    "p+1"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "0df96d89",
   "metadata": {},
   "source": [
    "* 多个符号的定义用空格隔开，隔开的变量互不关联"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "id": "ea1afa79",
   "metadata": {},
   "outputs": [],
   "source": [
    "x, y, z = symbols('x y z')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "id": "488f3324",
   "metadata": {},
   "outputs": [],
   "source": [
    "a, b = symbols('b a')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "id": "2a38691f",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAA4AAAATCAYAAACgADyUAAABEklEQVR4nJ3TLUsEURTG8d/KritqEJuW/QDrgrjBYlL8AG4zCGIRDGIyT/IDCEaLXRAsssFmU9cXTBa3WYyCQdAw98LsMCvOnvLAufO/5znPzFSSJDFKjRX09vCDnbLgUtC7smAbX3gpA9bRxBO+y4At1ILNRZzjA5/oYmEY2A7awI00pFPcYx3XmIHqEHAZK+hlzs6wJU39KD8xJnqYg+Aks86A1Vpo9sPt+XoPOpEHWxjHpeJEG0H7eTDafCuAYCNoNw/GYGYLoDns4vUvcBNTmf60dOc69oU14uuoSnfsYRIPuAgPdzCPA1zF2+LEpjStW6zhOVjbln6zqzjOeo8TH1HJ9DsFew5U0d/xrxoZ/AU/Py3Nd9dvmwAAAABJRU5ErkJggg==\n",
      "text/latex": [
       "$\\displaystyle b$"
      ],
      "text/plain": [
       "b"
      ]
     },
     "execution_count": 24,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "a"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "id": "7c8f4af0",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAA0AAAAPCAYAAAA/I0V3AAAA9UlEQVR4nJ3STyuFQRTH8c8VS3VRpNwFytJ7YGdlKwt1l7bW1JOF8iaUpHgLErds/HkUGwtrIbdYsFD+XAvzZJqmxK+mmTmd75xzfk2tKAp/VVcmNo9tXOMZTzhDs0roToBebKLEER4wiFlshPN6CnXQwH0SXw6VmznoJaxUd7hFf26mPqzgOMzyEap3MIGbdKZJ7GEIp9jBI94wigVcptAW6phCK+lgNexl3F4jVGplgLofu89j6DXsY+iJgAHsYgTvuIjba+MA0zjBPoYxg0N84qp6PHZvLszVwCLGsYS1kFdWibERbd8O5VSLL7m/96v+BX0B5mc1Ot6AyCAAAAAASUVORK5CYII=\n",
      "text/latex": [
       "$\\displaystyle a$"
      ],
      "text/plain": [
       "a"
      ]
     },
     "execution_count": 25,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "b"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "id": "4469d68a",
   "metadata": {},
   "outputs": [],
   "source": [
    "crazy = symbols('unrelated')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "id": "c0b82713",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAIYAAAATCAYAAABV0nVhAAAFSElEQVR4nO3aeYjVVRQH8I9tSlZUtu9Ji5XlNLbQRrZCRrSDRZRC0EIlRQtFhS22EEFR/RFBOG24UNG+SdoY0mJpRRbt2mJ7tFqa2R/n/pjf+737ZuY10ygyX3icN/ede+65557tXh0wYcIE/ehHFautaAV6CRdhOU5d0Yo0gW2Ezo+saEVyWFUcozXRN3sopy8drLd0bhYn4Q7Mwi9ivw9UmdboY6X+L7TiN3zQC3LgjR7KWdnWKuNKjBD2+gLDckyrQsYYjJ0xD//0UNZIYbAPeyinu2vRfMYYK6J81H9c90LshPVwTiOmqmNckRY9PsO7rfqaeEQauxHD8RC+EcadjX0zcg5Jc27BPngMP6ax3Up8J+IZfI8l4rCuwOoVeS1pH7nIOxUPikzyK37C6xhX4bs5rT8M62BZ+ns5TqvwdlcvIiOPx9tYjAW4FANExvhS2KsvMUPovLwzpmop6Sy97ZXo3NLYnonuJAz+AtrEAY/G49hBHEp1jeG4AE/jbtGMvS8M/ADG4CNMw184ChNFdjijJK9R5K2bdJkj6um32ATH4t70/ebSftuS3NlpHwVeSrRZvdbCkyJ45uFODME12BGb4QkrKaqOMVJEwsIMb84xikM+CAeoPZyHcYKI6FmZOQfiYLxSWedOYfybcBX+TuOXYCZOFwc6vyKv6hjLsTW+roxfKTLIOB2OMRXri4OdhHvU4/Ym9bpLOMXVuF5HhE7S4Wx93Xh2G+VSs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ASUVORK5CYII=\n",
      "text/latex": [
       "$\\displaystyle unrelated + 1$"
      ],
      "text/plain": [
       "unrelated + 1"
      ]
     },
     "execution_count": 27,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "crazy+1"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "7fd7e845",
   "metadata": {},
   "source": [
    "* Python变量和Sympy变量的区别"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "id": "bac8a558",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "x + 1\n"
     ]
    }
   ],
   "source": [
    "x = symbols('x')\n",
    "expr = x + 1\n",
    "x = 2\n",
    "print(expr)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "cc694f75",
   "metadata": {},
   "source": [
    "改变x对expr结果没有任何影响，这是因为x=2改变的是python中的变量，在计算时它使用的是Sympy的变量x，应该用subs修改值"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "id": "256af455",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAA4AAAASCAYAAABrXO8xAAABAUlEQVR4nJ3SvytFcRjH8de92QhFSFmUUgYlG2WTxeIvsFiYlIXFWRSZGI1ksVgVFoNV3WRQBllImMRAGb7nW/ce5zrX/SxPz7fn3ffz/CglSaIZlTP5Fs7xgA+84grr6PoLXEYrTrGDQ3whQQUDsbAlA7bjM8fZBtawisW8H/MgOErjUD2r9TSbxkp8yFqNWkEbOjCOyRTabATsrcpPMI/nIqt9KKVxDoPCWsaKwKgnHGNa2ON+o2DUPW4wgu7/gNCfxu8sOCz0lFVZOIAeXOKN2qnOYBsXuMOLMNkpYTiPWIjF1eAZ9jCBUXTiHbc4wK5w9L/AaywV9Fnjvyk1Df4AlgcsqeBGdRQAAAAASUVORK5CYII=\n",
      "text/latex": [
       "$\\displaystyle 3$"
      ],
      "text/plain": [
       "3"
      ]
     },
     "execution_count": 29,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "x = symbols('x')\n",
    "expr = x + 1\n",
    "expr.subs(x,2)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "2f8adb64",
   "metadata": {},
   "source": [
    "## 2、等于的陷阱"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "33a6cdf7",
   "metadata": {},
   "source": [
    "### 陷阱1：用于象征说明"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 30,
   "id": "06cb6847",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "False"
      ]
     },
     "execution_count": 30,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "x+1==4"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "12512422",
   "metadata": {},
   "source": [
    "这用于比较它们精确的结构是否相等，而不是象征性的说明他们相等"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "efdcc0af",
   "metadata": {},
   "source": [
    "* Eq用于创建等式,象征性的表示相等"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 31,
   "id": "c9732ee8",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAFgAAAASCAYAAADfVhk+AAACV0lEQVR4nO3YP2gUURAG8F80ZRDLNGIQEa2iFqIQQQQVbAwiiEVIRAtt9BQFlUSuUBBUSEgjREmCVprCwkYtIlG0sYiF4B+EKAEFtVCiUYvE4u2RY93L3eneHyEfPO6YmZ39+HZ23uxryGazFlA5LKo1gSLYg348xFfM4kZNGSWjQ+A2i4P5jsaa0Ckd3WjFFCaxurZ0ErFMKIIpNMWd1ajgLuHJbvmLa49hFZbgcHqUUkMDBvEZV5IC4gLfE8TYnZBoKPJdSJXi/BjF6+i+9Ygj2Ir9+JYUEBf4JGZwDovz7JfQiQGcSp3m/4k1QrH1YaxQULwHP8N1QcwOoWrP4Dhu4lAFiFYaGSwtI34ct4vENAo6vRP0mTcwjm7sRVZo2udxVxB8pgyi9YIMlpcRP6y4wGexDm2Yni8waZObRG9Eqh+PhZ78qwRyE+bGldwajHyjCb6hEnL+K1qEPaTU1VUk3wahai/jSbGbFxrTPub9P4DvxRJF6PXn67gWu4TKmIj5xkvMWy/ItYZX6Cn1gjj2CZvaBzTjqNJHpN4EW5cg8BAelJgnTWSk14ObhLERfhSIGYhWHzJxgXcKlfZcGD/GhC+TPrwog2Q9ISO9HvwT1wr41gt9+RFeitpHvsBtGBF68HahTfTgljCOtJdBsp7QkmKuabFP4TxkBYGHcTVnzAncijv4gm14H9lH8FR4xTcLZwLVRLu5B9sc/W4ytzl+womqMioTjVgpjGGz2IE3sZjTuI+L2FhVdmGD7IzZVkQL3qpzgRsWjisri3o/rvzvsSBwhfEbyzF50JTSEJYAAAAASUVORK5CYII=\n",
      "text/latex": [
       "$\\displaystyle x + 1 = 4$"
      ],
      "text/plain": [
       "x + 1 = 4"
      ]
     },
     "execution_count": 31,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "Eq(x+1,4)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "dc033745",
   "metadata": {},
   "source": [
    "### 陷阱2：用于比较形式不同的等式"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 32,
   "id": "0a250a41",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "False"
      ]
     },
     "execution_count": 32,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "(x+1)**2==x**2+2*x+1"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "e26fa74f",
   "metadata": {},
   "source": [
    "这不是结构上的相同，所以必然是false，我们要验证a=b，可以使用a-b=0，对吗？而Sympy提供了simplify函数（这个函数不能百分百的证明等式两边相等，参考官网原话）我们进行类似差的运算，比如："
   ]
  },
  {
   "cell_type": "markdown",
   "id": "2a11cccd",
   "metadata": {},
   "source": [
    "官网原话：\n",
    "This method is not infallible—in fact, it can be theoretically proven that it is impossible to determine if two symbolic expressions are identically equal in general—but for most common expressions, it works quite well."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 33,
   "id": "862d72c7",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAA4AAAASCAYAAABrXO8xAAABDUlEQVR4nK3STyvEURTG8c/Iihg2VhYiM29A/mRl1GTpDVjYUixslIWxsKYplpJ3YGtjRd4BRlNK2VlIkg0Wvzv1c+dOIs/mqdP5nntuzynUajV/UVeiNowjPOId99jHYL6pO4LGcIkhnOIGk1jHAmbxlHrxMEBrWMQmKthDGbupVUdRDasdRAO38Yol9MZgJfgZPiLwBRfowXQMloM3pHUXvBSDxeDPHcBWfSAGf1Ih+GcMtiYWpdWf78uDt8FLHcDx4I0YPA9e1f6FPln4b7iKwaYsihGsRuCOLL8TWZ5tJ7ciO7k65nGNKcyFFbdajfFKTUzgOAAbsvutY0a409SL8IDlRP2bfpPj/4BfAUMv45ahjIgAAAAASUVORK5CYII=\n",
      "text/latex": [
       "$\\displaystyle 0$"
      ],
      "text/plain": [
       "0"
      ]
     },
     "execution_count": 33,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "a=(1+x)**2\n",
    "b=x**2+2*x+1\n",
    "simplify(a-b)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 34,
   "id": "38c831ba",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAABsAAAASCAYAAACq26WdAAABfElEQVR4nNXVv0tWURzH8ddTjs+/EC4SPJPY4GRLYIKL4iIOEmFDk0EQVKTdQSHQ4BEXQcWkLR1bchTRpaUh0KAlgoJoCCp/DD4N51y8XbzeJ1KpL1zuPd/zOed97vf7PedUkiRxXnahpH8YjfjcOkvYJczi+99CymAVLOEr5s4aNopruIkfJ4xfE0I8kPNX8Cz2PTkJVouCGayXLPYeDjGBixn/NG5gHveLYC14jg94WAKCN1FfE4pJHHcXL3A7P3nWxtGBLuw2AYNHGESCKibxKsIPs8Lsn3XGVT3FVpMg+Ig6WoXq3RRyeJAXprA0fO8w9geg1L5kvkfw8zhRCqvishD7PUcbuYHHUTMf2/XcHENCQXyO7TtFK0pzto/FAs0VIY8b2PF7iHuxjLfCVlkXTpoZbBfBdhUfR0mELWMh4+/CqpCz60Iox7AibJ3+/ERlZ2ORteMlvqEbn6J/Fa/Rh6unAWsTSruBHrzP9T+I76n8wMq/dMX8v7BfeLRPqjZshrYAAAAASUVORK5CYII=\n",
      "text/latex": [
       "$\\displaystyle 4 x$"
      ],
      "text/plain": [
       "4⋅x"
      ]
     },
     "execution_count": 34,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "c=x**2-2*x+1\n",
    "simplify(a-c)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "07e98012",
   "metadata": {},
   "source": [
    "还有一种方式是取任意值，看两边是否相等，Sympy提供的equals方法，比如："
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 35,
   "id": "4e5e7013",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "True"
      ]
     },
     "execution_count": 35,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "a=cos(x)**2-sin(x)**2\n",
    "b=cos(2*x)\n",
    "a.equals(b)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "4e591c70",
   "metadata": {},
   "source": [
    "* 构建分数"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 36,
   "id": "2e9f2fb9",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAEUAAAASCAYAAAANBhNmAAAC2ElEQVR4nO3YT4hVdRQH8M+ooTaU6UJcBFpTVoT/QLJIC4vGsEUgtAgKBVuoiaISaBqOkSAYMqiJIjhTtgo3QRQaNUElLVwYKKahzULKDEUpNVs0Lc7v2fW++/Je3zQizBce575zfvf8fr/z/72Wjo4Og7geQ271AUrgXuzBz7iKXnRidEU9vehr8DmTXTisicMOBNpwEGPxMX7AY1iO5/EkzlXQd1EYNI8/sl8GwigL0IXZ+KriuzuEQZZhW4a/BSuwEYsq6LuAjhstyqfPARFO83L8FnQn2aYKh2gG96NdhP17Odl6XMKraO3vjfNGeQN/4x0MzfDfxXzsxur+PkQDPJPogXSmLH7Ht7gTj1fQORyv4E2RgrNdf0/UG+V77MUjwguSgpX4SLVQbRYPJXqigfzHRCdW0DlO3G+jqC1fJj1PZxcVdZ91+FPk3tKkYL8wUt5j/ydGJXqxgbzGv6ekvi48KwzTiknYhQn4DFNqC4uMclpYcbwobgdFjfmrxMa96ttdV5L1FMi6S16oCC2J9pVcv0FExq+4jCMi8rdgpEwBbtR9fss8L0xKyqBTveem4kW8L4yWxeH/0FWLhFEN5Hfn1t0sdmIVnqoxiozysiisZ0SoLcfikht0FvAWCKN0q9aSjyfaqGY8mGijmlMWZxO91sXy6TNXePQoJoth6TU83OTGN4OeRNvVn/MuMbhdwXdN7vNEoqdqjOxmM7FP1JR2kUJviWgaqNkki5OiHU/A6znZBuHZD8S8kkWbcOIdGd6jGFOwx3hsT88f1pi19JmCT0R+PodfEn8fDonwn4Wvy92n37BEFPqtonMcwwwxX5zA2oJ3vhCXvc+/NewlMV/14Ccx57ThBYzAp6JkIIzygGi5fZgjPJTFGnyOzaoNSv2Bk5iOt8VvnbnCYVtFtJwvqadHzD3TRLq0ipH/GzG37JXpYi2Dfx3U43b462DAMWiUAvwDyQebJv3MTFoAAAAASUVORK5CYII=\n",
      "text/latex": [
       "$\\displaystyle x + 0.5$"
      ],
      "text/plain": [
       "x + 0.5"
      ]
     },
     "execution_count": 36,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "x+1/2"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 37,
   "id": "f9af1988",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAEUAAAAUCAYAAADbX/B7AAACyElEQVR4nO3YX2hXZRgH8M/cCC9EAy/qIhBHiEI0bwKFEjVcaVhtKhLhH3IXiuD/yImDESaCgTMvCgpa6JWIIzL/FDjN2JWCgkpUopmgmQaG/8hqXjxn7LfTmTvH39qG+IXD7+V5n/c57/t9n3+/U9Hc3OwxemLYYG+gD8zFDhzDn+jErpxrn8I/+Aij0YA2/Iw7uIHvsUSKh6p+2Pj/iY2owU1cwvgCa98Qh23DPHyMy2jHRUFaPT7DzESnk4HxlMXJy6Y+xNrVGIeRWFZwbR2u4zv8iNfxDN5GI94RJP+KOYIg/JeUb8QB6lPyCrQmc1sKbq4ctOOn5L1FMArT8ZUIocPJ+N+U3hV8koyndgnTpLybLNyEyhL5h1iET7G+4AYHA6/hCezNoXsv+f27S5Am5RR2YgIWJLINWIPdWFrOTgcQdbiFb/vQq8LCZHywVJjGRsxHM0bgAxwSJKXdbyhiOF7FAdztQ3cLnsN+cUZkJ9pLaMEYUQ47RI75K8eGLoj4L30+T+baM+Zac9gsilpxmW196K3AWvygOyrQe0n+vWS8BLdzbqgFT6ZkE0V5/EKQVoqTOe0WQZ24wK8foLMc23EWL+OP0sksUt4SifUKnsZK+cthS4ZssSClFUdy2nlYVGK2qDY3etFZhW04LQi5mlZIh88scaNn8LxwrQbFmqbBxBTRvfYWOu8JQk5imgxC6EnKi9gjckqtCKEm4U0D2ZuUg3pRDL7MmGsS5zghPORab0a6wqcG+4TLzRDtMEHSceH+L4n/IAOJN5OHCGWYrDtBX8O6lH4HfkvZWYT3RSN3TCTZNC502a3Cs6IcdeIVnEspN4p6vxWTch2l/zBRHKgU1ckDv+gm5QXRxm/LsDM2+a0UOSULRyWkVDxCnw42iwusxvlyDA31TwdFUCc68rIIYeh/OiiCCf1l6FHylH7DY1IycB8wB5jSFGsQTAAAAABJRU5ErkJggg==\n",
      "text/latex": [
       "$\\displaystyle x + \\frac{1}{2}$"
      ],
      "text/plain": [
       "x + 1/2"
      ]
     },
     "execution_count": 37,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "x + Rational(1, 2)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "435d9da3",
   "metadata": {},
   "source": [
    "# 四、基本操作"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "9fb510bb",
   "metadata": {},
   "source": [
    "## 1、代换（stustitution）"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 38,
   "id": "6432c8f5",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAGMAAAAVCAYAAABSQFBJAAAEeUlEQVR4nO3ZeYhXVRQH8M9oUWakpIlh2IJkSaTYgkWFgdpCpC0IQZa5ZIrtVhoKUjZJZUmb0TrZgoVSkhXaYi5JlJEtZlRii6WplBaWmmV/nDvMm+eb3w9nRv1FfeFxHveee959Z7/vVU2cONH/qAy02NsbKIHpWIfWTZBxAnZgaLPsaDejUo1xIi7FZGxugpwP8TIm4cCmb6tRuBgPYBF+Fc7xbBFjpRqjWmx8WjPIuhMdcU0zyGoMxmM0euCHUoyVaIyj0Qcv4o9mkPc+vsAItGzE+sHCm3s38vnXi3c6CCNLMRYZ42S8IKy4FWswDwNzfAOxEJuE0j7FOOzXwLPOx1tJ3lb8iAUYleMbgqq0hyLME8q5MDdehZo0Nzk3NwOdhZH3NObjK7GvksgbYziWYECiU/AqOqivtGqhrGPxPB4UyqjGXOybk3slZqMbXklyX0MrXJHj7YO/8F4De74Jf4s6kPX0e3A5HsPY3Jp3E+3bgMyKwD6Z+254WOTq07E8x3tYoqeICPheRNHaND4OL+E8obDqzNoR2IbuokPKon3mvrXIrSs0XLg/xjNC8YNENNyKG0Rqu6pgzQeJntGAzIpANjJGCuPcbmdDwOpEhyQ6SZ0hYDtuFF47rGD9dvxZML4hc99JePuaMvsejy2YKIrjHSIiB6Xn57Ep8XcuI3evImuMXom+XmZNz0TfLpj7UhjtSLTNjD+HA4SR7xNp8JCC9e0S/aXMHlZjKg4XbeMSUUO2lVjzs/pRWIRvRG7PXk+lufkFczVl5O0SsmmqbaIl2y+0SbQh710jPLANNqaxe0UEjBIt5nXiZRaIlLY08dV2T/uX2zjWZ+6H4vcy/K2U786mqu9ERNrsj6eFsbJYVkbeLiFrjI2JdhKtYEPYlGhHrCyYPzTHV4vp6WqLU3GBSHlzRSOwTl09aac0LhEFe23ax7VKt40t0nNXlZE7tWBssDBGDd4ps75JyKap2u7lnDJrPkq0d8FcF1HoV6kzbh4bRSc1XLzgwaJhIKJqPbqWeP65wkuX43jhOMNwTIk1XUW3t6wEz15H1hjTRJGdIDqrPGq7qScTHa9+3m8pvLUFnsitPVv9KKxFh0RrU8wOcXZpLwybx2mYKWpGP2G4CUl2/myRRW09nF+CZ68jq6DPRU5/RHj/bHFYaSe+Ff2GM0WxvAs34zOhnM0ioo7DYtyde84M0c0sFnm3SkTDSeL70ZsZ3lm4CGfh68x4d8wR6a+vupo1U9Sc/knmooL37CfOLrNL6GJ3YUC6iJRKHA9q0v0GjGFnb31MKHiMSEMDEvMneDzDd4sw2GhcJg55K0W0TLFzVzNWKLenSDNb8G2SM039lncWfkpyH0pjXURt2ZHk5GvVOLwhnKBXbq5Neo854my0p9FDnImyOCpdhB7GQFWF/s8YJw6NPdXVqMbiatwvDnxFUVMxqMQPhcRZ5Dvc1kQ5rYRhZ6lwQ1C5xtgiTtNLNe3n0hF4VEoDlY6iDqdSsDBdTcEK8cnkX4FKjYz/JP4BQRMCVpmUncQAAAAASUVORK5CYII=\n",
      "text/latex": [
       "$\\displaystyle \\cos{\\left(x \\right)} + 1$"
      ],
      "text/plain": [
       "cos(x) + 1"
      ]
     },
     "execution_count": 38,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "expr=cos(x)+1\n",
    "expr"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 39,
   "id": "172c0d73",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAGMAAAAXCAYAAAAfiPFCAAAEmklEQVR4nO3Ze+yWYxgH8E/FSE1NaRHmNNFsWiJsWiaHHDP0R06JtBLLirSlNVo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RrCp6uxTZBfpMxPQHxS6bIS4rrcQu/BWniDBxJ27Cp3hWpKE9cLRYqLty/UwT2cxcEXcbCW84Tnw/eiOjOx0X4gx8VWbc88Tdpbk4L1ZXmefp4u4yo4rejkDP9BChnbgeTEnvqzCULXfrQ2KBh4ow1DMpL8LDGb1hgrBBuFxc8paKHTpW3CmyuFksbiecJYj5OtmZqH7KOx0/Jbv3l5lgKfYvsKUX5tEizeNlcTfa2eiIK3Jlh6aHWIeh0KhG/2cMF5fGTorPghdxtgg/Cwrqs7hOXAS7ii+nNYta/FBI3EW+wa0Fdb1xrvCoakQ0FcROV+NEUHyo1gLW4zJxRjUT51ZvHCbC12JxZlXDwZisgS9nOwq1SgaRVZW+vl4i/kusFYfwYHUZWCUswaiGH9qOQS2TkcXk9PyrUatnxn8S/5NRQ/gHJQMELSmEmfUAAAAASUVORK5CYII=\n",
      "text/latex": [
       "$\\displaystyle \\cos{\\left(y \\right)} + 1$"
      ],
      "text/plain": [
       "cos(y) + 1"
      ]
     },
     "execution_count": 39,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "expr.subs(x,y)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "eb66dbfd",
   "metadata": {},
   "source": [
    "### 使用代换的原因"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "fdadeaf9",
   "metadata": {},
   "source": [
    "* 取一个点的值"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 40,
   "id": "799208da",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAA0AAAASCAYAAACAa1QyAAAA9klEQVR4nJ3SvyvFYRTH8dfl/gcGs90fcWWyGMiIgU1JGZRS30w2KcVguP+ADCIWEpNSBkkyyOImKZPBz+H7qNO3b/d++dTTOZ3nvE/n8/TUsizzV3WFvAfT2MEd3vCKM0zF3nqAxrCBRxzjAb0YwRaGUs93hG4xjD18hfoizjGaBmzH9Y6wWwCghc2UN4qe2uk9xY+qUB0TKT+oCq2gH/s4rALNYh43GP8ttoNmsIZrDOClEzSHdVwloBUvy6AFrOIyAU/FhiK0JDd+gUE8l60Rf8QklvGJU/kjFHWPZoT6UuyWeyrTCZpxvQy1DqdR5qmS/gX9ALg2MQ/Qmy4sAAAAAElFTkSuQmCC\n",
      "text/latex": [
       "$\\displaystyle 2$"
      ],
      "text/plain": [
       "2"
      ]
     },
     "execution_count": 40,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "expr.subs(x,0)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "71861ff4",
   "metadata": {},
   "source": [
    "* 通过代换研究一些式子的性质"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 41,
   "id": "4fc0f95c",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAABgAAAAUCAYAAACXtf2DAAABfUlEQVR4nOXUMUjVURTH8Y8ptDgFQVuDDiqRDbqlWwqCCAqFUDTUEDiIYqBS9AgFUUFBHKSlaItGl6LBSR2KaigcdBMUJKJFUEEd7hX+/L1P5D2dOsv93985537/59zDrSgUCi7TrpSZv4nBnHYHe2i4CMAKmnPaDN7g92UAetCIVydCuYBV1OAarmISr/GnGOAzjtCd0yvwNvomMvo37KMJAzjAfDYxD3iOQ4yhMqNP47HQ2+GMvofv6MQohiKkKOAn3qMej6I2KkzKBzxz2lbQF9fFvLMqkfACD1BANcbxKQIPE/E/op4f12QFhNmexU3MYVm4k/3UAXiIBfxKOVMVwE7m+wl2Ez92Pfpu4X6Rc5IV9AqXuh33/YmYVmwJbevB3/MCOvBOKPc21vAUdbm4pZhbL7SwqGUBd/FRuIM2oU0vhTZOnE49n50AGoUR+4d7Qvki8Cu60FIqoFYYwyO0YyMXMxLXqVIAVVjHjTNivghPRUlW7mP3HwCOAX1CS1MAmtldAAAAAElFTkSuQmCC\n",
      "text/latex": [
       "$\\displaystyle x^{y}$"
      ],
      "text/plain": [
       " y\n",
       "x "
      ]
     },
     "execution_count": 41,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "expr = x**y\n",
    "expr"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 42,
   "id": "4b34bbd0",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAB8AAAAYCAYAAAACqyaBAAAB0klEQVR4nO3VO2hUQRTG8d/GlFaCYJcigtpksY8IKz7QQhQStRALLUQIgihoiLKCYjApIjaijWInQVBUNFoLPhoVwdfaGFAUAikUfJBYnAlZrmvIZu+18jR35ps58585c+bcUrVaVaCtxjDWpf4W9GIPtBdJxgusQgltOIltM4NFw3/hPTpRwX18+FdweIy16EN3/UBbiwv34Ds66rRzeIulqf8IZ3ERk3nCR8W9DqT+YezEJnxJ2htM4ELWudWwT6Mft1FL7Upqz1hf2tTPrHOrJ4cxPMEp8YyeJr0Tr/EVNxo55pFwFZTFQT7X6TWsmMsxe/IxEcrtGb2Ey2lssE4v4zoO4CZON7PrLPwIpkQIF9Xpw6IqXcLRpHXgDoZwBSewEWsWCn+Gq6Iq7U5aPw7hGvYnbQnu4pbZ0z4X2X9mvvBGdz6AHahicVr8XtrMVJozkTaYtd75gmmc7eMYEWE9j4ciB340s/BC4cwWCNiLb3mD/wbfJRLsU+ofLALcCL5ZZO5LdOEV9mFl0fBuka3j2CBCf1wk5eCfrvnBy+LZTGI9PiZ9VJTLrZp4v83Al4unNC2KRC0z51j6DuUNb8c7LJtjzgNRXnO3PP5q/+FN22/CVFvMj4EmZAAAAABJRU5ErkJggg==\n",
      "text/latex": [
       "$\\displaystyle x^{x^{y}}$"
      ],
      "text/plain": [
       " ⎛ y⎞\n",
       " ⎝x ⎠\n",
       "x    "
      ]
     },
     "execution_count": 42,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "expr = expr.subs(y, x**y)\n",
    "expr"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 43,
   "id": "694c6f23",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAACMAAAAaCAYAAAA9rOU8AAAB8UlEQVR4nO3WT4jNURTA8c9jLG2mFEmzodh4UkpiM/InKTVFLGRBkUQ0ykxGr/ytmUKKwoLsmCghptmyYYOUYqxGJoqUxFvMWJw7+fXrPfHevDezcOrXvffc073fe+4553cLpVLJVJFpk7TvbFzCAlxEoVkwj7E89S+jEyP4gh4cxBi0NAHmOLoxiBnow0zMQxk/xw2b4ZmHmIsO7BYOOIsuvMfSccNmeGYZWtPG5aTbldpjWcN6PbNZuLktozuPN5glPHIVqzEHS/60WL0w/XiJo2ncia1Yj2+4hf14h1MiYKtKvdc0JoLzPoZSvz31YUXG9k76GgYDA3iKE9iIZ7UulL+mAXHajpy+gGtp7kxurh3FtNbHWkEqwRzGqDjl9Iy+DztwBUcy+iJuYy/u4uREwjzHDSzC9qTrxiHcxJ6MbRseoBfXRZquw6qJgiEy4wdK2CdO+yjBjSabVlHM7vntjRciu07XClMpgIdxTlzHBTwRMVTO2HwW3svLllpBqF5nPmX6O/G9nk3+VirBbBMBO5LGB5oBUglmgwjGV1iM1+I/srDZMCtFAA5jrbiqHhFX+drSUJiiyIyvWIMPSd8vKuomdaTsv8DMF6k7JurEUM6mK7W9jYZpwVvxJq0mg9IbtdEyWQ/yivIfpppMKZhf2h1hNIPibN4AAAAASUVORK5CYII=\n",
      "text/latex": [
       "$\\displaystyle x^{x^{x^{x}}}$"
      ],
      "text/plain": [
       " ⎛ ⎛ x⎞⎞\n",
       " ⎜ ⎝x ⎠⎟\n",
       " ⎝x    ⎠\n",
       "x       "
      ]
     },
     "execution_count": 43,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "expr = expr.subs(y, x**x)\n",
    "expr"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "83f70a00",
   "metadata": {},
   "source": [
    "* 形成可控的化简，比如："
   ]
  },
  {
   "cell_type": "markdown",
   "id": "e9ca03b0",
   "metadata": {},
   "source": [
    "官网对于该段的描述：\n",
    "The second is if we want to perform a very controlled simplification, or perhaps a simplification that SymPy is otherwise unable to do. For example, say we have sin(2x)+cos(2x), and we want to replace sin(2x) with 2sin(x)cos(x). As we will learn later, the function expand_trig does this. However, this function will also expand cos(2x), which we may not want. While there are ways to perform such precise simplification, and we will learn some of them in the advanced expression manipulation section, an easy way is to just replace sin(2x) with 2sin(x)cos(x)."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 44,
   "id": "e6e47fea",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAARQAAAAYCAYAAAA7xQK2AAAHjklEQVR4nO3cf4xcVRXA8c8Wf1BRWymQGoisiREhxBr8RVVKawuKQaiiRKPQWopQVKw/UGvauGqtRC3WHwGiKAUVq6nRRkWrCNTWRqXEVQERJVD50UYaXEBthWr949zJvn37ZubN7szs7O58k8l9ue++++6558y599x7Z3r6+vp06dKlSzOYMtYN6NJlHLECt+BRPIQf4vgxbVGH0XUoXbqUZy4uxyvwauzHDTh0DNvUUbTLofTiANY3sc5r8XccMoo6XizadV5TWtR6JqPMncRrcDVuwx9xDg7HK6uUn3T6yjqUGViK7+Ov2ItHsE0I00mzmZfg7bgU/xpFPbfiB1iNp4++WS1losg8nuysHs8Q7X244N5E0Re8CV/CVhHuHcA3iwpmlfdmfBUvx2+wDt8TMeJV+C56RtigB3CsiEGbwRoh2BVNqOvTmImLm1BXK5koMrfSztrNOvTj1wX3Joq+YCXejReJ73JVsg7lLpyBo/A28eVfghfgPpyFN46wQU/gTuwa4fNZno8FwvD2NqG+34q2XYCDmlBfK+g0mReLUWruCJ5tpZ21k89ijnCQ/83d6zR9jZb3CZmeiWW1CmYdyo1i1fp/uTK7cWW6npu7dwZ+IRzFf/AgtuCiXLlew9dQsnm92IA92IcdOL1Km5eIEew7Ve7/LNWbN8qe9K4DYhqaZQOeI4wgz8vSux4QMu5K7zi7oOzZ+KWYwu8VcfYKPLVKW8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0bO2/FCYYBLxTmHahwjpq79mbzKCv1pJdr1u5TOLbj3PLFoeI/qs7EB1fuvnTK3k0bsrF26GDB6O56o+ipF3qGsEotjtwpPV2tx9bWKZzhHpLTe9G0kHBBnCw4TxpHnVdgo4tNThWJXiXbm9/WzVGL07I7SFSLsWiV2GfJkdxa+ntKVhsbfB4lRaAq+lnu+bP+1U+Z20Yid0VpdNNuOJ6K+SpPtyEX4hFgg3ar4mO+9BhfdNohYbVvK7xHe/KXCUG5oQXuJY9pniR9qZQ8VzcKPxFT2FIMx9EYRB5+Z2re1oM5ThdybMnl3iLj6SjHqbRKHe2aI32k8ZvCczHZ8Bh8S0/eNYsvwNLFzsU2crMzSSP+1S+Z20Kid0VpdtMKOJ5K+iIXqhem6slU+26CO9kg7XT2ZP1jqw8fqVLzF4FTyQtFhs9JL9okt4G+LEeWxzHO9Ypp5jYi/q+VluRknG/67jqeILeWd4vcgxEiwTZyCPBl/yD2zAD8Xvx05MXdvmohjNxvstCyzRWedJGLYPan+q4QhZHmL2AKcJQ5P3S3O1Kw1fKGskf5rt8z1WCx2euZpfA2lT2N2lqUVumhED2XpNH2Nlj61dbZTfJ+HOJTxxApxMOkEgzHzSHmPOP04R/HI0ClMRpnHM5NSX+PVoRyMPwsv//pR1DNVjFzbxU+0O5nJKPN4ZlLqazz990SWfeIA1A6j+/OaXnzF0JOOncpklHk8Myn1NV5nKF26dOlAxusMpUuXLh1I16F06dKlafwfMSYN1RNsK40AAAAASUVORK5CYII=\n",
      "text/latex": [
       "$\\displaystyle 2 \\sin{\\left(x \\right)} \\cos{\\left(x \\right)} + 2 \\cos^{2}{\\left(x \\right)} - 1$"
      ],
      "text/plain": [
       "                       2       \n",
       "2⋅sin(x)⋅cos(x) + 2⋅cos (x) - 1"
      ]
     },
     "execution_count": 44,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "expr = sin(2*x) + cos(2*x)\n",
    "expand_trig(expr)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 45,
   "id": "7e4fe667",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAOUAAAAVCAYAAAC5WykPAAAGxUlEQVR4nO3bf4wdVRUH8M8WVComrRZJDSqrMSKEWIOoYFSKFhSDoqhEE7EVCiIqNCpqDY2r1krUav0RIf6iYMRqSrRR0foDqNTGHyVWtIg/CD9rGyW6SLRVq/WPc1/2dnZm38y+94Ytu9/k5U7uzD1zz/fcc+65984bGhkZMYMZzGDqYFZL7xnGPqzto8yr8Wcc2oOMZ4p+nduXHg0e01HnNtAPXpui0g65U87DUnwDf8Ru3I/NqWFbDlwHx+P1uAz/6EHOzfgmVuJRvXdroJiOOreBMl7b8IVKO+TCX4PP4zn4GdbgWhyLL+DrGJpkB3bgaCyfZPsiVuHvuLwPsj6M+bioD7IGiemocxso43WQvpCj1A5D2ZryhWL6/g7+lz0zHz/HE/Dq1LkHE0/FbYKc8/sk87d4JJ6M//ZJZj8x1XRegitxMm7sU38eDFTx2qYvjLNDPlNej28VOgG7cEW6Xli493L8CDvxL/wJm3Bh4blh49eUed0w1uE+7MFWnF6hxDkiSn2t4v73k9wzC/VD6V37RKqSYx2eiEUl8p6d3rVD6LgzveOskmfPwo9FqrMbvxbZwSMq+lqXv7Z1bgOD4rUup1TzOhlfoE92qJsb/yeVe7O687EBxwgFVuM6zMYba8qFI0X0GcaXBUHHJtknlzy/SESUn1bIu0SQuRIHZfUfw2KRlryn0OYnqTylUH8etuAVqVwtoufhxht5Ver70bgGnxHGWIWNeFjh+Sb8talzGxgUr03HZDdey1DmCx30xQ4H1+jEwXhDuv5eVv8m/BsLxM5VjsNqyO1gIUbw/qzumvSuS3BDVn8oniGm/KrNjl8J516Ms0WEei/eLtYCF5S0+UUqX5DVHYPPivXG87G90Obx2fWJInLfI2aAXal+udgsOD3psiprU5e/NnVuA4PktcmYrMNrEVW+0EFf7FBnprxMzFzXiciUY6+xyJHjvhpyO7hLRJYcG3G3MESOI0QE2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YVcSLeKUidKyLmLeLTrPWFZ18rtsEXiEPt28WZ62rBT44m/LWtczcs0ftndoPgtQmnlPNKM1/oux2GDtD/Uy4XB8bHGVt3TBZvw6fE4W1ZJJsqmI46t4F+8toUpXY4UJ3yEPxORKWX9SBntoi6W8QHxlMZ01HnNtAvXpui0g5T6T+STbBHHOBu1dsfU4fxOZFGTXVMR53bQL94bYphFXY4UGfKGczgIYsDdaacwQwesvg/nALRSxGgFWAAAAAASUVORK5CYII=\n",
      "text/latex": [
       "$\\displaystyle 2 \\sin{\\left(x \\right)} \\cos{\\left(x \\right)} + \\cos{\\left(2 x \\right)}$"
      ],
      "text/plain": [
       "2⋅sin(x)⋅cos(x) + cos(2⋅x)"
      ]
     },
     "execution_count": 45,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "expr.subs(sin(2*x), 2*sin(x)*cos(x))"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "02b6a562",
   "metadata": {},
   "source": [
    "### 执行多个替换"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "007868c3",
   "metadata": {},
   "source": [
    "传入一个数组即可"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 46,
   "id": "8019a3d1",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAABsAAAASCAYAAACq26WdAAABpklEQVR4nL3UPWtVQRAG4OdKKo1Gm1TaRFRSKhIj2mjgYukfSCFYKcTCRhT1WAhpgjGiGPzGX2BrI4hf/0CNBETBzkJUrmm8Fjvnejiw51wR8sIy7M67++7M7kynKArrhQ0t/ln0Y5zMcLbjPr5gDR+xiG114kiD0A7cwA+MZjg78QrjeIJ3mMIZHMMhfC3Jucg6eBDE2w0XuhVCcziOcziKa9iDq1VyTmwuNp3AzwxnAl0pbTdrvsuxbxabmsQmMY/reJ4REpeBp/hd833HS2zEdE5sBI/xCecbhEhpgpWM/0PY3dXDq7iEvTiMXovYWNhvGX+5vrVcqEY2JUWzgNctQsOgE7ZfFyvTt4KLQx5W3nws499S4w3ERqXcTuKXv4Xcl34W3In5Yszfhx28SQ27wg7etHyzNdzLbNonveOLEChT/CxsNy5d/ZGbpYLu4U1drCffjooQe4S7lfVV6dt3cVrqNiWuSPW1rFKnTe1qGJyS2tUSZvAWB3BESt+FKrmtEbdhFfvxMETOSv1yCQdV+iLDRVbEyOGz1NZa8b+R/RPWVewPvlxTu+z3iDcAAAAASUVORK5CYII=\n",
      "text/latex": [
       "$\\displaystyle 40$"
      ],
      "text/plain": [
       "40"
      ]
     },
     "execution_count": 46,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "expr = x**3 + 4*x*y - z\n",
    "expr.subs([(x, 2), (y, 4), (z, 0)])"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "48ccbc13",
   "metadata": {},
   "source": [
    "其他情况：\n",
    "It is often useful to combine this with a list comprehension to do a large set of similar replacements all at once. For example, say we had x4−4x3+4x2−2x+3 and we wanted to replace all instances of x that have an even power with y, to get y4−4x3+4y2−2x+3.（带条件的代换）"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 47,
   "id": "7f9696b3",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAOUAAAAWCAYAAAA/z1uhAAAFd0lEQVR4nO3bechUVRjH8c9rQkGbtJhI0UJRQZatZLbYYiuVFBFS5ptmZIu0GKVlve1GRVlR0oJaClFBRRG2WZlYkKmVRUmCqJRp2WqrZn88d/TtNvM6y513ZnznC5c7c+6Zc8/vnvOcc57nnmlpa2vTpEmT+qFbhmWNxTo8nGGZ9cRl+AQ/J8f7OK2mNaouY/Ch0LoSL2O/mtaoi5CVUR6OEaLTbqosw/U4GIdgBl7E/jWsUzUZgEdwBI7DGryJ7WpYpy5B9wzK2BbTMBw3ZVBevfJS6vsNGIl+Ns3B6KTU9yH4Cf3FrNmkSmQxUz6G58XMUU8MEcvpdbgo47I3w2BshdkZl10O1dSaY2vRX1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nhtm+ZK4YstEAa5ooO8WWttVXp7Fcs8YfQ74rv0THmqGAk+E6H2mWI3xQSxVKhH/sSTBa4dJHyvWeIdY/vlXlfSSmPqbc91wo+cj4H4roO8jaa1d3Jey3+Xr0eK7XLLcKKY+sfhOfEwBnVaFUvjd4W3lrWJjjpF7P7I0ZW00rh6c4zDrfhI1L+jJWs9at1HvK1YnkrvJqKvPYXP+wMbjPIAvCKiigPFliZC3Byxlj5KhHAbna6klcbXO1QY5FpRx1F58iwWwZZ61Xqy2BU1U/jc34sI7DEi0LNcbFlFGOWeIoq4TvwzYFGqwDFiv949YptQI9OVtLJp6N09OW+m8O6pd8WyvV61vin+uNFfDBw9xDv9hSJw96B2s3++QE+TJk1qSKP87aVJky5D0yibNKkzmkbZpEmd8S8KSePreAYELwAAAABJRU5ErkJggg==\n",
      "text/latex": [
       "$\\displaystyle x^{4} - 4 x^{3} + 4 x^{2} - 2 x + 3$"
      ],
      "text/plain": [
       " 4      3      2          \n",
       "x  - 4⋅x  + 4⋅x  - 2⋅x + 3"
      ]
     },
     "execution_count": 47,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "expr = x**4 - 4*x**3 + 4*x**2 - 2*x + 3\n",
    "expr"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 48,
   "id": "4ca5455a",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAPUAAAAaCAYAAABvoxoyAAAGaklEQVR4nO3cf6wcVRXA8c8rTSChSPmlDRGNiAGNaEWUIghFREEDEg0hVLBPECOiDb8RpPWJP6hBtAVCq2BoEROjhB8KBrWA1lJNqKUqoDYSX6RRsFBAwQq01j/ObLsZdvfNzpvp7O6bbzKZ3bnz45zdc+8959yzOzQyMqKmpmZwmFS1ADk4G7/Hv5Lt1/hgpRJNXC7FFlxbtSAlcQkeEHa2Hj/GmyuVKAP92KnX4XN4Ow7Gvbgdb6lQponIDJwpBthBZSauw7vwHmzCMuxeo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7H3rrVdajNNjLGc0YV/z01mJbIME3Yzb5iaeugxgnpmfpR7QPyVjRGu4YbtBZzu7i+mfVNr8/Af3Lepx15dcvK2SKue0QkVDqtZebVdQGmpo5Nx4ewVBhTM2sy3LNh6IfgVpG9P1d0lKUZ5crCAsXJntfe+lHXdjwhaiRWi89h6wrQUEE/6JiKpzOeu9DLM9WniAqlJ8QItNg216cfOAffFHHl0cKVa0fRug6LWeAo/CLH9buJpaBfiUz2suReB4sZoEyG5ZN9qnz21o+6ZuFBMWjshSeLiqlfwHfatB0k4p4VYn057Sp9QIxeD4tlieWiGmihcGN7nYtFHL1GJFue7HBuL+r6NP4oDHuWGJQWKd/Ix0Nee+tHXbOwd7LfTHGJso3al+WNiA95qai0auZwUW64Du8Tbulc/FB0lBMLkq8s5uJy/FbI38nl7mVdV+BN+JYYlC6rUJYs5LU3+k9XIkx4RtRANDMJXxK5pZUS76XKH3S8FXeK5MQxotySMPxVIv54t3CVepHZokNvFjLOaXHOqEiC9Lqu94tSwykixqyitnl70Y+6Hisq2paL3NBTIgN+pEiUPS7Kd1Fdp95PZKy3iF/CPJpqv0TUuF6pfbFA1bwu2e+gfTXbL8XM0Ou6/jXZP6C9Wzso9KOuy8SPaA4TE8RUUR+wViQMr9Y0OBWVKKvpb34kindmCGMfZAZe10H+eWBNNmaJUsNFBtTIm5gQuvbjnyTUjJ/XCAN/vShpfRgXVSpReUwkXVF36onKsbhCZFTvEDmBoot9eoWJpCvqmLqmZuCoY+qamgGj7tQ1NQNG3alragaM/wPvB/kZG4dGiAAAAABJRU5ErkJggg==\n",
      "text/latex": [
       "$\\displaystyle - 4 x^{3} - 2 x + y^{4} + 4 y^{2} + 3$"
      ],
      "text/plain": [
       "     3          4      2    \n",
       "- 4⋅x  - 2⋅x + y  + 4⋅y  + 3"
      ]
     },
     "execution_count": 48,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "replacements = [(x**i, y**i) for i in range(5) if i % 2 == 0]\n",
    "expr.subs(replacements)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "449e9869",
   "metadata": {},
   "source": [
    "## 2、字符串转化为SymPy表达式"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "f1c54c19",
   "metadata": {},
   "source": [
    "* 使用sympify函数（不要和simplify函数混淆），这个函数可以使字符串表达式转化为SymPy表达式"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 49,
   "id": "30f2494a",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAIAAAAAYCAYAAAAyC/XlAAAERklEQVR4nO3afajfUxzA8de1JWUeQiwpWdSUbInysCeWGcLukJTZaiMPhTGxteUSmkZmaoTaZf4SlmYMe2DTkocZIbFlbDF70rQhZvPH51z323ffu/t78ru/ub93nb7fe76fc37n8z2f8zmfz/nelra2Nk16LwdV2X4qPsKv2IKFOK3aQTWpH9UawAjMxbm4ALuxBEdV2W+TOtG3yvYX5f4ehx04T3iDJg1OtR4gz2Gpz+017rcUHsFSbMDvaQyf4j4c3QPjqYSr8CRWim11L14sse1x+BtzhL6TsABrxfvYgfcxUWbeq/UAeWZjDT6ocb+lMBmr8Q4241CcjTbcmO439MC4ymE6BmEnNmJgGW2vEBO7AFfjKfyE5fhBGMhYPIeLk8zeWhrALAzDUGGJ5TIB83A+3q2g/eH4o6D+IUwTAestFfRbTyaLiV+L4WLySqUV27ACLbgci7AnIzMNH+JKYQyv5LeAt4XbGZurb0F7ejaz4Mcfw/UYmQbfExRNPryUrqfk6ivV9b9kOb5Nv10OR4ggfKFYfMvS/Z6c3CY8ne5HsG8McHdq9CD6ZOofxXg8i3tzbebgOrFyvypz4PXgsnT9PFdfia6NyqU4GK+WIPtXuu5m3xjgM8wXL2CcWAnTcKdYSTfl5OeKyR8jgq7+qX5nKj3BFPQTq+JMDBGTn1/N5erayLRil4h/9kdf4alhcUdFnum4RgRP/cQe+pZ4SXmXcnO6Ls3V35/a9wRTRMDTwWIRX2wpkC1H10blEIzGm7reBjuYKQ7q3hB6FqaBG0U0f6JISVaJffLPAtmWLkpbNwNZL/a5bJmXni0veNbeTX9Z+qcx9E/jHiDSwTMKZMvRtRQd9ldKTefKZZQw3gXdyN2Gu/C1MHB0nQZmV8tE/FbFAIuYjSNzdYNFKvO8eLlZ1lTwGz+Ll7Ia3+AFxcfUleq6TvcrLsuPZciWQ6sw2EX7kbkVT4gYbaTMOU2RAVwrAqFNYhXdrtPV14rZBXUThAG0qywN7IrvheKDcQy2Zp5Vo+vI2g2xYvqIIHeZOOgp4g48ji/EmDdnH+a3gEvECvwSpwt3MUl5BxKNyPHpmj2f+D/oOkyc+nXl/u8Rk79GZGmb8wJZAxiCl8W+OEq4xhnCS9Q7Hy6XgTozkCwHicDuWLG//5LqD2Rds4wVweprBc9mCF0+ESt/a4HMv1vAILwu3MiF4giReEkfC9c8VJxRNyKjxUnkCrE3bxOZwHARBG7CDUm2kXUdkwqdBn2OziB4q8hysvKrRLyTZTweEB5vpQgA86xHe1+cLFKCveLr3rqc4FSRX84S5+mNyBI8I75CDhIB5i4R/M0Xh1XbNb6ug8XkZRmQChHPdBjAWThBuPg8J6VrHxEDFPEe2lua/xF0wPKwMNgB+K7STmr9ObhJ/WgVp5kVTz61/xzcpH6cWotOmh6gl9M0gF5O0wB6Of8A5gcelRfPG+oAAAAASUVORK5CYII=\n",
      "text/latex": [
       "$\\displaystyle x^{2} + 3 x - \\frac{1}{2}$"
      ],
      "text/plain": [
       " 2         1\n",
       "x  + 3⋅x - ─\n",
       "           2"
      ]
     },
     "execution_count": 49,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "str_expr = \"x**2 + 3*x - 1/2\"\n",
    "expr=sympify(str_expr)\n",
    "expr"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "66e6b624",
   "metadata": {},
   "source": [
    "## 3、预估数值（evalf）"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "689587cc",
   "metadata": {},
   "source": [
    "evalf函数，可以使用它对结果得到一个预估的数值"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 50,
   "id": "c302a416",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAMYAAAASCAYAAAAANKFkAAAGRElEQVR4nO3abcxcRRUH8N9TqlhFIhG0XwwpVQOKWjBUQIFKiooSLUgNolVRXkzQSpCA0aJVP1BIMPiSKPgSGyVBRCXQVgWBWIgiiVgTQbFYqj7VUloQi61F+uCHM9fn7n327r1zd/nk/pPN7N6Znf85M3NmzjlzJ1auXGmMMcboxazS9xfibPwID2I3Hsdd+FClbRu8DbdgMvW1Cd/HMX3aDsOdw1PFMjydPmePSK4PlPqs++yt/Od0fBl34p+pzXcHyD2quWrSv4suuRxlHIcf4O/Yk8pb8NY+bXPHDCbwQdyNndiF32A59ik3nF36vhRfTcLcgb/gxTgN38DJqc3TDeRwOS7GDtyI7Xgp3oF34n0VJbpy5/KU8RIxsE9gv5o2XeTagM/W9HccTsSPK89X4DVJlkkcWvP/YeSqoo3+G+TrkstRYAU+L+ZwjdDtQByBRVjXp33OmMFqYajb8D38C4vxRRyvNGYTJVfqRDwPazFV6mwu7klKni4sehDmYgsewauTEAXeiNvxEA4pPe/C3YWnwARuxTz8EBfhHLGoyhjVmBT4JY4WhntTRd5JsfufIBb7tXhvTT/DytVW/y66dOFYiuvxM2HcOyv1z8J/Ks9yx2yJOGEfwkJhgEXf16f6s/Bteo/c23Gz3oGGrfha+r6ohrSMg1O/v9K7WCXhd+KgyvMu3F14CiwXi+sssWvUYVRjAoeLhbRFLOiqvBu1O41HIVdb/eswSJdcjlni5N+FM800CmYaBfljdloqrzRtFEXfl6bvHy0L1QaFYE+1aLsRTwqrPLBSdzyeL3aGtqjj7spzGFaJ43N9hhxt5arDean8pma/fBg0yTUK/Zt0yeE4Vpwq6/CYiBkvwce0ixPbYm4qN/WpK54diRfQG2PUYbbw1eEnLdo/KhT7Au4Xvv8OzMfbxfF6Xt2fM7i78MzGd4RP/smW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vhpXRhbsLTy6GGZPDRFDXJuheIBZ7GYeYTlD8We8kj2qu2iJHly7YJgxjhZjHo8XCXYvLxEt/VSyQN2bEZnqGuIeZg7+JE2yViqs2MX7tfIwxZiL3VfIxxvi/wNgwxhijD/4L9zOD88dmsqcAAAAASUVORK5CYII=\n",
      "text/latex": [
       "$\\displaystyle 2.82842712474619$"
      ],
      "text/plain": [
       "2.82842712474619"
      ]
     },
     "execution_count": 50,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "expr=sqrt(8)\n",
    "expr.evalf()"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "0b65018c",
   "metadata": {},
   "source": [
    "参数为精确值，默认为15位"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 51,
   "id": "31701bb7",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAABP0AAAASCAYAAAAg/qspAAASkElEQVR4nO2de7AlV1XGfzMkvIQMGCFTPirJDI8EEK4RYmIi3AkQIgS4oYilFqMDkkiBxlFTSAUwEy2KgJC6iBQPAYVAFUrkEcyIeZAiICJV4ggEhITJRRNIQgzEvIjCxD9Wt7enb/c5e31795ortb+qWz3Tp/dZz2+t3fv0Y8OuXbuoqKioqKioqKioqKioqKioqKio+OHBxt7/XwdcAfwHcDdwK/AvwLnAoc7vfj7wZuBTwH8B9wLvc4zf3oy5F3hxQRkrne/t/93YO3YD8CLgs8DtwF2YP84C7jPw3Yc2un4YuBbz4W3Ap4HfYK2/u/gF4G+AbwH3NNtLgWdm2tBCia0i51mN3tc3cvYCHwSOHzne6+MdM3Rq/35QQI7XX2rslbh4fdxHCrdapOZlVO4rtnh9rNZBb1ymzrEdxHAFtFoB8JPAu4FvYrFfAZaBh/aOy8kvhS85HJuqd0XUypy+7eGxkmNevigyptZrBxonV2YcP8YvNZapnFT1Ah+/VO577IC4uUgf8+qFkpNeGeqYFdLjHzGfVnu3J1d2zLB5Vty9PSWqFveREncvt7x6qZxX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NoAWW6+cfVizeBnms9OABzbfu7uRcemAP7w+bnE09rDZ60l7ALpHjuIvJfZeOaqPFXjzMiL3FXh9rMReiUtUjsG0XAGtJoFNHJ6INflTMB9+C7P9PPa3X7FdiUsUxxbw98eIWqnopfDYa4vCF8VfEXqBLyYqvxbwx9LDSUUvhV8K9z12tIiai3ih6jU11tt8WuWikiuQHne1pywQU4u9UPw19XxS9XHEPBd8Pos8l/KOUXSL8LGilzePS6+RjMFri+KvqHUEL1R+LeCvlcoYb6+PqJWufNmwa9euBL0rKioqKioqKioqKioqKioqKioq/r9g44FWoKKioqKioqKioqKioqKioqKioqIs6qJfRUVFRUVFRUVFRUVFRUVFRUXFDxn+F43uNjNtSpiBAAAAAElFTkSuQmCC\n",
      "text/latex": [
       "$\\displaystyle 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342117068$"
      ],
      "text/plain": [
       "3.1415926535897932384626433832795028841971693993751058209749445923078164062862\n",
       "08998628034825342117068"
      ]
     },
     "execution_count": 51,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "pi.evalf(100)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "1bc0e3cf",
   "metadata": {},
   "source": [
    "可以用于代换精确值，它比subs更高效"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 52,
   "id": "773ec363",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAOAAAAASCAYAAABCd9LzAAAG8klEQVR4nO3aa6xdRRUH8N+tRQWhxaClMRrSVpACaqlSqxQFrAXrIwWt8UF9EFECWiM2+KDagiEWDeSCkaQ+UEQT1CqoLWqhktQ3H/AJSrEVlVehFrHQUtTqhzU7d9999z7n7Ln09Mv5Jzdz7p418581e2bNWmv20MqVKw0wwAD7BhNqnj0bV+Fe7MZdGMbTM/pv29drsB53Yxe24Ft4aY3sO/G/Ln//7WGMS0ry766pH8KZ+CV2YCd+jaV4Uod+2+jSL55LsAF/T7LbE8cK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
      ],
      "text/plain": [
       "0.0874989834394464"
      ]
     },
     "execution_count": 52,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "expr=cos(2*x)\n",
    "expr.evalf(subs={x:2.4})"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "6199566e",
   "metadata": {},
   "source": [
    "有时，循环误差小于评估表达后留下的所需精度，可去除"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 53,
   "id": "faafad72",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAIAAAAAWCAYAAAAIAZSVAAADsklEQVR4nO3aW2gdRRzH8U+kImraqIj44LXVxopgFKlVQaOFKD71oSKi8d6HVqkKPnitsWARSrGNNXivUvvmgyIoiGnFOypUpXhpjVSR+mAVq5ZYrcaH/xxz3GaTk82e5EDOF4bZndn5nx+7//3Pf2ZPS09PjybTl4OmWkCTXC7EK9iFISzO9N+Nj/ArfkzXnjGKvXuSnfXVjU0HaFwOx6e4Nae/E304H5dgP97AUSNcuwBL8Fm2Y0YJQpvUh9dSyePSzHk39uACEQ0qtGETbsKKrJF6R4BuEXaGcHOB8cfhWREG92En1uLIcuT9x2I8irdFSB3CCw2krxZmiuf5c6b9SbyIzSMNqmcEOF7c1N/RWmD8HLyHY/AyvsR83IbLhKf/VIpS7sOZQuv3OK3B9NXCWnyCD6raluAU8SKOSL0iQAs2iBvweEEbfeLmLsci3CXmukfQjocmrHKYOzAXs7C0Tvp6DEfDvNJZUP9qkTRegb9TWztW4Wr8mTewXg6wXNyMG7C3wPjZ6BIh9bFM3wPJZrdIlMpgC3aIh1Avfesxb4zyYQHta3AtFuLrqvbzcDS2iQRxPy7CsnR8CPWZAubhYazDW8IRxktlzOv4J9P3G94VD2AB+ovJnBBF9O1OpUx6cSUuxueZvpfwcaZtg3D0VVJUKDsCzMBGfCfWnUVpT/X2nP4dqZ47hp3T0YFDJ6BlJMrSNxqtQntHOj8pHZ+QzvtwPa4Sid+xqVTyrV/E219d9qZrt0nRrmwHWIGzkrDBCdhpS/WenP5K+xFj2HkVWw0/sLIoS99onCO0b03nq9PxynS+VGT+/fihqtw5nh/JTgE7ceI4xm/CNel4vnjr1+D98YgoQEuqa52zJ5sy9L1ZZWe03xgPndmGrAMM4I9xGNxVZWejCIn3FxCWpfIGteX0z8pcl8eNOAzflKCpmrL0TTlZB1hY0E6r4fkuz4GeSmUdbh/D3lepzptDT0113hxcYcTNjxIoS9+UU9YqYB+eyek7W+QF74gbV8v0sCXVXSJPqc60Z4pNlkH/3/SYTBpdX82U5QCD8rd6e4QDPI+nR+ifg4PF9PNXahsQS6wu3CJ2FCs8KNbXTyi2x1AGja6vZhrhY1C/SDxPFklohWViq7VXTE1f4Fyx5t2Oe0vUsCgVYilFbKQ8l453OzC7nkx9daMRHCCPAbEUWin21i8Xy5xe8ZZlP3pMhA5cl2mbnQp860AHmEx9daOl+Y+g6U3zDyHTnKYDTHOaDjDN+RdpXOw/Zp3zJgAAAABJRU5ErkJggg==\n",
      "text/latex": [
       "$\\displaystyle -4.0 \\cdot 10^{-124}$"
      ],
      "text/plain": [
       "-0.e-124"
      ]
     },
     "execution_count": 53,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "one = cos(1)**2 + sin(1)**2\n",
    "(one-1).evalf()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 54,
   "id": "bf98f2e8",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAA4AAAASCAYAAABrXO8xAAABDUlEQVR4nK3STyvEURTG8c/Iihg2VhYiM29A/mRl1GTpDVjYUixslIWxsKYplpJ3YGtjRd4BRlNK2VlIkg0Wvzv1c+dOIs/mqdP5nntuzynUajV/UVeiNowjPOId99jHYL6pO4LGcIkhnOIGk1jHAmbxlHrxMEBrWMQmKthDGbupVUdRDasdRAO38Yol9MZgJfgZPiLwBRfowXQMloM3pHUXvBSDxeDPHcBWfSAGf1Ih+GcMtiYWpdWf78uDt8FLHcDx4I0YPA9e1f6FPln4b7iKwaYsihGsRuCOLL8TWZ5tJ7ciO7k65nGNKcyFFbdajfFKTUzgOAAbsvutY0a409SL8IDlRP2bfpPj/4BfAUMv45ahjIgAAAAASUVORK5CYII=\n",
      "text/latex": [
       "$\\displaystyle 0$"
      ],
      "text/plain": [
       "0"
      ]
     },
     "execution_count": 54,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "(one-1).evalf(chop=True)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "5aa4a250",
   "metadata": {},
   "source": [
    "## 4、使用其他库运算（没彻底搞明白）"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 55,
   "id": "4aa12778",
   "metadata": {},
   "outputs": [],
   "source": [
    "import numpy\n",
    "a=numpy.arange(10)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 56,
   "id": "d8dafc4f",
   "metadata": {},
   "outputs": [],
   "source": [
    "expr=sin(x)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 57,
   "id": "5bd7962c",
   "metadata": {},
   "outputs": [],
   "source": [
    "f=lambdify(x,expr,\"numpy\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 58,
   "id": "607ac399",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([ 0.        ,  0.84147098,  0.90929743,  0.14112001, -0.7568025 ,\n",
       "       -0.95892427, -0.2794155 ,  0.6569866 ,  0.98935825,  0.41211849])"
      ]
     },
     "execution_count": 58,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "f(a)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "8b4d0c06",
   "metadata": {},
   "source": [
    "# 五、打印"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "3a7ef8bb",
   "metadata": {},
   "source": [
    "直接看链子吧，https://docs.sympy.org/latest/tutorial/printing.html"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "7f5fed19",
   "metadata": {},
   "source": [
    "# 六、化简"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "7740cbbb",
   "metadata": {},
   "source": [
    "## 1、多项式/有理函数化简"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "1ef03a60",
   "metadata": {},
   "source": [
    "* 通用的简化函数symplity"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 59,
   "id": "f310c80c",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAKIAAAAYCAYAAAB5oyYIAAAF00lEQVR4nO3aeYxdUxwH8M8UoZa01lQIIxFbBLHF2ox9iVhDIrHvGltQVCoZWwlKY6toUISUtKFRSwW1Eyoq1lhirVoaWvtS6o/ffZnrzr3vvXlznzcd75vcnJdzzjvnd77nd37Lubeju7tbG220GkNaOPcYvIof8C0ewqYtlOf/hgHFfysVsQs3YwfsikV4Aqu0UKb/E7oMIP4bUcROLMbkfs69F+7AW3gTR2J17FjlP3fhG6zQ4JxbCdmPb/D/gwl95b+/3FOF/1ZaxCxWEvJ8V9C+NY7Alfi5wTlew4O4DCs2OMZgRTX+y+CeKvw3oohzsbGIMcrEBMzBywXt40Q8M7Gf81yBETijn+MMNkxQzH9Z3FPAfyOK+Cfew7wShKrgaozEofgrp30D7I778Ws/53pFyH8ylmpwjGOEi+nqpywDBdX4L5N7CvjPKuL+eFIo2e/4Es9gVKpPp94xYrquE1MwH79hNvarIth4HIXd8GFBn+PQgfsK2h9P5j84U9+RyLRYuJUKpmAdQXCrsK1Yz1zB9TyxjsNy+h6GZ7FQKMObwiMtm9O3nj1Moxb/ZXNPDv9pRTwJ07GJSOXH4xEMxbEFQmSxrtD4TtydCL9pMu4uOf2vF7HHLninyri7i5Na5LZH428Re6St3DU4GpNwQar+haTco8qczcSJeBEHJuV4PIw19FaYcYLHjXEvbhSbPA4zsUyqb1/3sB7+y+aeHP6XTjWejD+wuciO0litQIgsutCNi1N19+KxROBZqfqbBQkHigB5RFL/U/JUsAK2wLuKA+U3hOIfL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Nwkj5p7WN3iiLewr4H0ifgdXCdeJi/JJ+jDFUkDpNWwn7gjK4pwr/S5Ii/iZu6mdr/OPMTtyq99ubNqqjDO6pwv+S5JrbGMRYkixiG4MYbUVsY0DgH1Q20KVjMAUaAAAAAElFTkSuQmCC\n",
      "text/latex": [
       "$\\displaystyle \\sin^{2}{\\left(x \\right)} + \\cos^{2}{\\left(x \\right)}$"
      ],
      "text/plain": [
       "   2         2   \n",
       "sin (x) + cos (x)"
      ]
     },
     "execution_count": 59,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "e1=sin(x)**2 + cos(x)**2\n",
    "e1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 60,
   "id": "4464cff6",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAA0AAAASCAYAAACAa1QyAAAAh0lEQVR4nO3RIQ7CYAwF4G8EPY0kCIIbllsg8NNIkknEfwcugOAeCE5CgkQR/GZ+1WTLMFM0eWlf05fXtEVKya8xC/yACx74oMUtiuaBn1Hhixc2Y5xOWKPEsW+96HTvGxxyGhV/0eSi+Nx9Bixy3uGa6zeaKNqiDr1VBjzRxPUSigEsmfIQHbJ7ECMDdcssAAAAAElFTkSuQmCC\n",
      "text/latex": [
       "$\\displaystyle 1$"
      ],
      "text/plain": [
       "1"
      ]
     },
     "execution_count": 60,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "simplify(e1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 61,
   "id": "8409f732",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAGcAAAAmCAYAAADZRYUwAAADoklEQVR4nO3aTYjcZBzH8c+uLxVUxGqLIKUePAr1sCjYWrTgG3iootSDguBJEbz0YhFdRRFZBN8o3mz1IrIqaH1BtAqWoqhUrRRBvShV6JYKqwhqZT38MxCHnUmeJJNNbb4QZpJ5kv9v8psnefL8Zmp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0mN6cDtOb02H+BbIHLlEiIvq8AAAAAElFTkSuQmCC\n",
      "text/latex": [
       "$\\displaystyle \\frac{x^{3} + x^{2} - x - 1}{x^{2} + 2 x + 1}$"
      ],
      "text/plain": [
       " 3    2        \n",
       "x  + x  - x - 1\n",
       "───────────────\n",
       "   2           \n",
       "  x  + 2⋅x + 1 "
      ]
     },
     "execution_count": 61,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "e2=(x**3+x**2-x-1)/(x**2+2*x+1)\n",
    "e2"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 62,
   "id": "bcad4b93",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAADIAAAASCAYAAAAZk42HAAABg0lEQVR4nO3WP0hVYRjH8c9VR2l2C0JCl3QssEk0cFFEEAdpqKEmSQxUFO6gIOggOLooNYmjizo4CE0tDUEQQYJYkIsSEQ7q8B7hcDj3es/leryIX3jh8JyH931+vM+ft1AsFt0FGm47gGsYwgr2cYoLfExzbMoxqGqYQQf+4hBtpRzr/Ube4TEe4G05x6SQHeH6BhP2Ataifws1CbEy9vA9OrcsSSHvcY45NMbsS3iJVUzWJsbakhTyBR/QjtHINo1xbOBNfqFlI63YZzCMIpoxj21B2HlukWUkrdgPsYyHQuv7JNTMWQX7/RTyudKV2kqroVT7/RP7foV/Fe73A/8znH+UwbcsaUJGhOL+jRaMuab1xeiuUVyZSaZWH9bxFU/wDa+VGUT1QlxIFzaFGukV0mtWuLU8Z0dVXKVWB7Zwgh78iuyb+Ix+PBfePHkyEC1CmsMzYTjDMSYIQlqF9nqBF0LBxpnCLhbx9GbiLUmnMIjjPIoWHIiEFO6f8XXGnRFyCdfFTbqm31lTAAAAAElFTkSuQmCC\n",
      "text/latex": [
       "$\\displaystyle x - 1$"
      ],
      "text/plain": [
       "x - 1"
      ]
     },
     "execution_count": 62,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "simplify(e2)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "7f46a63f",
   "metadata": {},
   "source": [
    "* 阶乘函数"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 63,
   "id": "46be0913",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAACcAAAAVCAYAAADFEfeTAAACK0lEQVR4nM3WTYhOYRQH8N87LEwzRY2FUsNiMmx8xMICq5lRNmQjxSijWFGiEPWSjxFCFgoLHxs0U5QNKTUiHyMsNDY2qGEUUZimzGvx3De32/ved9w7yqnbuff8z/Pv/zydc+5TKBaL/lerGweOyxhCQ8b1C1FCVxJIiiuN4ZkSy1+EdejG94zinuEGDqIxDkyssmB/Ctlw7P0wvuFsRmFlO4LH2BpxpoorjoFwFtpwAT9zinuC19iMo/hFvprbiAKuVcDuCCWwOhEv4GKEdSewq2gWNiyvuDZhh48qYDsxKtTRhFj8ODbgPHYl1jyIfHtecQ2YjwGVG+ElrmAO1kexPdiO69hSYc3TyC8rB6rVXC2bLpzIYErOXqwR6rcRh3A7EjtaIf+r0GzN5UDWk2uK/JeUnPc4hRk4g4dCDY6krPmMqXnFlbtzUo28T7H3LvyokV8f484sbijyTSk5a4UG+BB9b6vBWScM+KF4IIsNCqfSWgVfgUt4hbnCDNuE2SmcrcKoeZFXXAl9Qn20JLAl6BFqrkPYxD6h+ZKzLW6LI38vrzjojfzyWGwebgmd1+5PN/egHyuxtApfhzA3b46XuI/ojL5bhFFRigS/SeTvjvyxClyTsUrY2LtyMDnnCn8hbgSnhR/1AjzHtJT8uyn8nULnn4gH897nTuItDuTgqBdOtRf340BeccPCxO+X/bI5E+ewIwlk/X3FrS96stqAKle08bim/zP7DaLGc/Te+13ZAAAAAElFTkSuQmCC\n",
      "text/latex": [
       "$\\displaystyle \\Gamma\\left(x\\right)$"
      ],
      "text/plain": [
       "Γ(x)"
      ]
     },
     "execution_count": 63,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "g1=gamma(x)\n",
    "g1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 64,
   "id": "803c7c68",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAE0AAAAVCAYAAAAD1GMqAAADOUlEQVR4nO3YWahVZRQH8N9JH1KDjBskRDYQDRANGNFDheVEvRRWRJAKKVEEFQ00kHATqwsVJhFF9dD0UKFUNJAViVM0KFRU9lAkFV27RWFQStPtYX2bu93uc84+ex+uYv1h8+2zhm+tvc761lp7twYHB/2P3nBAH/Z4GiOY0oe99iXMwCgWFxnFoI1WuKbm5E/HFRjCb312up8YwBK8iC+xEzuwUQSlLHm24CUsx0F5xsQ2Ru7q4MCu3P09+BWPdPd7r+JS4eMw1uIbHIb5eALnJ5nRgt69eB/XiWcFrUJNy5RaFRw5Dl8ko1f19gzjjvNE+XgN/+To0/ABjsAlWF2iuxWTcQz+pllNu1IE9/kS3pviD5hfoLfwZOINNbDdK97BK3YPGGzHo+l+Zhvd5zAdszNCk6DNFpF/r4R3S3JwOSbk6PdjER7HbQ1s9xN/pvWvNvxNaZ2TEeoGbQpOFalb1gA+xjM4EQsS7Q7ciBdwdU27/cZELEz3b7SR+TCt5+SV6uBwkUHDHWTuxGUYFN3nbqwRQSwek72FIZyE14VvZdghmt/0jFA30wbS+ksHme/wII7EQ3hX1Lg/Kuy/TbXxJ7ue7dF/oiPeJJrZgi6yP+PQ7EfdTNuZ1gO7yP2Yu1+M3yvu/5XdR5tu+L4HWbgWK/E5ZomgdMIkY89cO2gjaR3oIHO5KPzbRWu/HtdU3H9WTb+q4AaswKfJzkhH6TiNU/F1nlAHwyKLjm/DvwBP4TOcLI7AEpxQ016/cKsI2Ec4V/eAEc/YSjqoH7RRrBfn/NgC7yysEjVtrgjuUpHV4zmbFbE02d8iMuyninpnpnVtRqh7PInp+WLME+9zcApeFR1njrHuugqbcSHOxoYGdutgEZaJuXKDaAJFbBODdxFzk97LGaFp0H4Qc87DIuPWiCycJ4p5HrfjLdxn7N8bLxyd1gmippVhnT2DdjAuEonwbUYsHs+Wau+dxOiwEmfgNJFt03AIPimRfzvtPd4BI2bFVpdrZoneQjEhPJAnNv2etkJ8MVjWcJ99EZPE6VitUE6aBm2XGAw32/8+Qh6Fx3BzkdGkpmVYn679DVvFsd4D/fjc/Z/Dvxtrtp5TUGG2AAAAAElFTkSuQmCC\n",
      "text/latex": [
       "$\\displaystyle \\Gamma\\left(x - 2\\right)$"
      ],
      "text/plain": [
       "Γ(x - 2)"
      ]
     },
     "execution_count": 64,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "g2=gamma(x-2)\n",
    "g2"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 65,
   "id": "3dde1bce",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAIIAAAAVCAYAAACKYDYGAAAD5klEQVR4nO3aW4hVVRgH8N+xoRKjC9ODUNQ8SBeILhRl0MVwNOihogsRpYIKFYbd6YLSIFbzUFj0UFQP3R4qHCqKyIqkrOiiUGEXupB2UyYpDEqxiz18O2bPOvvss4/OjOeM84fN2qy9vrW///98a61vrX1qfX19JjCBSQ3qn8QgpoyhL6ONk7ETCyq0HY/8KdGgKBBOwZXoxx+j69duoRsL8Ty+wTZsxTuCaMptHV7AchxQ0m+n8IdL8CDW4HfxIz9d0r6hBkWBcHfW6UMj4Oho4lI8itPwAe7HAI7DY3gOtcTmHkzF4pJ+O4U/LMG1OBE/VbQp1CANhKPQK0Tctlsujj6+wvk4HFfgdszHMfgBF+OixOZDfImrsE9Bn53EH24QPh+IayraFGqQBsJ8MYqeLejgNTH1pOLW8Hj2rL+iMyOBN/ES/k3qN+Ph7H5Ggd0zOEL84CnK+NN+GqzG19l7W0GdBmkg9OIfvF9gfIsQfbnho+lezBPT9G0tOjRa+Csr/y549m5Wzip4VsafztKgDHUa5ANhilhrvlCcJH2Cp3As5mR1d+BGMZVePbK+7jK6MDe7f7Xg+UdZeVZS34w/naNBM9Rp0JV7eJiI8k0lHSzBZegTWeddWCVESafoPYV+kTC+InxLsRXbxdSYRxX+dIYGzVCnQX5G6M7K30o6+FFk50eKbct7Yr3cUeHlG8RaVvUq2wY1wmLcJJKhOSXtfsWhSV0V/rS/BlUxTIP8jPB/lrx/kw5+yd0vwJ8VX/ytiMKq+LmFtrAID+BzzBREG2Gy+l1BVf60rwatYJgG+UAYzMpujXG5SIw2i73odapvW2ZW97FlXI8VWJ+9Z7Ck7SQcjO+S+ir8aV8NWkGdBvmlYZOI9KMbGJ+HJ/AZjhfT70Kxb9+TuFUEwcc4R3kQEPxqWfs8mvGnfTVoFXUa5ANhJ94W68a0xPAMrBTr42wh2FIxo4zlvjnF0uz968Ro21LBZnpWrk7qy/jTvhrsCuo06EoaDIgTuXPF+T2cgJdFpjnLUFa9EmtxAc4U591jiXlYJvb9axQfG28QBz15zM5sXixoX8Sf9tXgwuwilik43RDnLbi5wK5Og1ryGXpffI+N4gx/mviIsx/OxqdJh714XZz1Tze26MOdTdq8Zfjp4kFibV9lSMA8Uv50tgYb0ZPUFWqQnizuEJn3qThJjIqpOES9APCGWGvGWgBChFqTa0ZiM1fsCu5r0GfKn87WoKfAplCDoq+PK8SoWDZS3rYJJosPUwPKp/Dxyp8SDYoCYbs4jFlrfP0xowePKF4z8xiv/CnRIM0RJrCXotFf1Sawl+E/tzcp7lwSYJkAAAAASUVORK5CYII=\n",
      "text/latex": [
       "$\\displaystyle \\left(x - 2\\right) \\left(x - 1\\right)$"
      ],
      "text/plain": [
       "(x - 2)⋅(x - 1)"
      ]
     },
     "execution_count": 65,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "simplify(g1/g2)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "f8018796",
   "metadata": {},
   "source": [
    "simplify它只化简为它认为最好的情况，比如我们希望将下式化成平方和的形式，它并不能做到"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 66,
   "id": "461e75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fnGkNb+a8ZZmZvY7RexxeXwtDp07Wes8MQnrmZUlOCYzXF/vC3h30i2fO3ok9AzXpfQM16VcAVyY2F1U6yvkAAAAAElFTkSuQmCC\n",
      "text/latex": [
       "$\\displaystyle x^{2} + 2 x + 1$"
      ],
      "text/plain": [
       " 2          \n",
       "x  + 2⋅x + 1"
      ]
     },
     "execution_count": 66,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "simplify(x**2 + 2*x + 1)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "34ce93f8",
   "metadata": {},
   "source": [
    "如果我们知道了我们要什么形式的化简，我们应该使用具体的对于函数，比如上式，我们希望化成平方和的形式可以使用**factor**函数"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 67,
   "id": "8850dc4c",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAEsAAAAYCAYAAACyVACzAAADT0lEQVR4nO3YW4hWVRQH8N+oD4ndLRoITCKyIGqiCLuJlRfopejyIJRJBiZEYRSoGHxEF6EkKzKoh6bLQ4VCkS+WoSiFeIHppkFFdhFLxSiwRMrpYZ2Tp+35Zs53xvk+kfnDZs+svdbe6/ufddnndDUaDSOohlGdduA4wiJswR/Yiw9wSVFhhKwjmIoVuAY34m+sxZm5QjOy3sAejBte/9qKK9CPuU3WZ+I1fIkvcDfOxrW5QhlZV+IuLMWBY+jscOAOvIiNIn368VYT3W14D0/g5Ap7nyL42Z8Lysh6Kjv45aoedxBL8AB6sKuC/tPoxoMVdJejD5tyQUrWhZiGd/FXhQ2HijkiGqbWtF8gfD4V8yvob8bXmIfRA+g9gym4E//kwpSse9GFd0o2+FD8sNsSeRd6s7WlFRw+lliHb7Kzq+JtTBBBUYZlmI2b8G1xISVrmmByk6PxKA6LnC8+lWdxD17Fwhac7hQ+yebpJWsviHp9A7ani0Wyxonc36G8sH+GN3Gx6BSwGA+LtL2/db87gi3ZPCWRrxBlYZYo6t3Z+K8ZFMk6V0TM7gEOWoKDaIjC+iTWCPIO13S+3fhd/IYJiXy+6IAfCw7y8UiuMKagPD6bfxvgoJ9Fl1goWvanooYdquDkTpzXZG1diex18aSHA/txTiLrGsyoSFbe/U4axGZv4e+5+HNQ1wLLcXoi68EtgpidyVpfxX3rYKwa3b5I1p5sHl+mmGGWKOi/iHx+SLWWTZCVYo4gqxfrK+4zVIwSD+37OoY5douomdRE92YRAV/hUnFfuQ8XtXpohzFJpFxfq4ZFsvqxAWfhgkTvOqwUNWuGIPUxEZntvlsNFZOzuaxODogxyf+rcLt4qcwvZJdhtegi0x3pliuxVaTR9eL9rN24NRtEWYCrRVrDPoVulmGGuEu+3+phZWT9Km6wL4kIWyOibia+S/QX4SPxejBZ+9EjLsRFnJ8N+MH/yTpNkLsaP7V6WHqDP4TncRUuF9HVjTPweYn9WpH/dYnqzezX17RvZPbNxsREf7bo9svqHFb21eE5/IjH62x4HGOsyIRVapaMMrIOihv5VifWx7+JeMXRNawy0pqVY0M2TiTsEGlbGyPf4FvACFkt4F9jSKJg0sBn9QAAAABJRU5ErkJggg==\n",
      "text/latex": [
       "$\\displaystyle \\left(x + 1\\right)^{2}$"
      ],
      "text/plain": [
       "       2\n",
       "(x + 1) "
      ]
     },
     "execution_count": 67,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "factor(x**2+2*x+1)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "f164a939",
   "metadata": {},
   "source": [
    "* 展开函数expand"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 68,
   "id": "ff826684",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAG4AAAAWCAYAAAAhKqlXAAADG0lEQVR4nO3ZX4hUZRjH8c/mXppEXuRFEIpEQaiX2j82RaUuKtQuJNMlvUiKNC3SUBikQLBoK7AgoZW6iqCLIso/bWGIUMEGFZEFqwlJSmCIianrxXPS4eXsjHPOnGUG5gsvc+b9d97fed73eZ/znr5araZH93FDyfZb8S3+wSl8grvKDqpHc8oabgC7cTcW4iIO4OaS/fZoQn/J9kuT/0/gDO4Rq69HRZRdcSk3Zn3+3eZ+mzEd6/AxfsO/YgJ9g7Xar7MqVuAtHBLbzzg+yKtYdsWlDGEUR9rcbzMew9v4EyM4jluwDHvwYFZnfJLH1SrbMBdncQJ3TFSxnTNxF+4XD+hSgfaD4sEOFGj7Kx7GrXhcBE1PCuF/YLkwYtUMKq4BnsPtmIb1jSqmhtuX3TgV2YfhrGxnTj+vYTUWCVc12Xwp9tTLSf5JvJNdDyRlRbVWyQiOug7PkBruBSH+ZUypy38Va/AutiRt3sQqPICfi423Uv7Lfi8m+UW0dgyp4X7A+7hTRIjwEjbhQzyV1N8t3MNKEZDMyNLUaobbMv3CE8DnSVmrWjuKvD1uG86jhmfwCr4Q4lJXtF5EkgdFYPB/er6a4bbMTnEg8JnQkNKK1o4iz3AnRHR4mwhND4t94EJO3b4JUq3JfceEH69P72VlIzllw9cjJuFZbMYvrq2olFa0pozljLPdGiZkoteBU3XXa3GunTcVD+umJG8eHsFe8VDqGW2x/6fxhthzF2n8XllU65BqNTQkz3ArxQZ9UuxXGzQJTQswlJM3KEQP46sSfW/E6/hRGO2vBnXLaB3KyRvUHg1NSV3lQ2K2/IQ5ws2s0+BFsMN4URhtVES5jYzW1VrrDXcvPhJ+f4lwIdvFqpzs95kibBfj/F6stNMN6na71quuci4+Fed7i0VkSIj7Tiz/+8QZWieyBjvEic0hEZikjAkX1slaH80S4bphgWuBzWlZxN6P2SIEHhen/b8nnW3FfnGkNb+a8ZZmZvY7RexxeXwtDp07Wes8MQnrmZUlOCYzXF/vC3h30i2fO3ok9AzXpfQM16VcAVyY2F1U6yvkAAAAAElFTkSuQmCC\n",
      "text/latex": [
       "$\\displaystyle x^{2} + 2 x + 1$"
      ],
      "text/plain": [
       " 2          \n",
       "x  + 2⋅x + 1"
      ]
     },
     "execution_count": 68,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "expand((x + 1)**2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 69,
   "id": "0f90aab8",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAGIAAAAWCAYAAAA7FknZAAAC3klEQVR4nO3ZT4hVZRjH8c8dSxCUQFLaiAgJBWK0MPHfqI0aTItIdGFkBRYYiAOiqKVywQJFRTFw40apTWYrtT9ii1xkUEgtigIVF9FkDtpoaGX+WTznwOl0B2fOOVfv4P3C4b33/Xd/5z7v87zPeU+tXq9rc//pKDl+I77BFVzEEUwpK+pBpKwh5mEfZuJZ/IsTGFty3geOh0qOfy73fTn6MUt4R5tBUtYj8oxJ5rxU8bzDmTn4GL34OymPozvbqaxH5NmD7/B1xfMOVzZhK/pwVBjhUTwtwvonaccqDbEDnWIF3Kxw3uHKUmGEE1iMq7n2h7Nf8qHpOG4nA7PUcCBp29bgR3fhFXThTAHRVVBUezPowHZcw0v+bwS4kR+QZR1u4R2MyNTvxKvYjw25MXvxMubjx4LCq6CI9mYxE5NE6LmM57EePZjRaEDeEN/jfTwpMiB4C2twCCtz/ffhNSwTG/RjyTW61G0UY6jam8m0pLyA02J/2Cb20K/wJcZlBzTKmjbhL9SxCu/ic3Fzt3J93xSZ0hdiI0qvtSVvpChD0d5MxiflSozCAvE/TUn0dOKj7IBGhvhFWG4i3hMWXIx/GvStDXDV7yL0vIjZg70+uMt8RbQ3U08aGmtYIhbqn/gBLyY658qEqYGypouZzyvEplMlZ8XKHSy/DqFvEe1V67mclOdEyMxyXXjFCjyDUzQ2xDKxwf0m4n2PCEFV0lXxfClFtVet5+ek/GOA9tRQo9KKfGjqxkHhQlPxE17HE5VJbB6tpP2kOHebjJEN2tOD0fNpRdYQs3FYxK9FwsU3C6+5V/l3UVpNex8+xCPYkmtbKM7o+vFZWpka4imRYvUnHXuT+sP4Fi+IJ+ZWpFW1rxEPt28LD9kpMqVPxcnDGzKhqwOPi83jtrDU2dyEG5NyRxNFF6WVtf+O6diNCVgtXhUcEwvjP+lrrf2GrjWo+hi8TUHahmgR2oZoEe4AY1/Maolj/2oAAAAASUVORK5CYII=\n",
      "text/latex": [
       "$\\displaystyle x^{2} - x - 6$"
      ],
      "text/plain": [
       " 2        \n",
       "x  - x - 6"
      ]
     },
     "execution_count": 69,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "expand((x+2)*(x-3))"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "ce3b56a9",
   "metadata": {},
   "source": [
    "它似乎并没有使式子变得简单，但这种情况可以使式变得更简单："
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 70,
   "id": "2840291d",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAPgAAAAVCAYAAABrCyNXAAAEl0lEQVR4nO3baahUZRzH8c81KcWowF4ERflCsiBKKsigRXEJgkpaiCjzokJFZTtlKF3CyhdBt3pRVJAtLyqUiiIyIStL2iSL9oW0TTEpDMposxf/I9575szcc+eemTMzd34wnOFZ/+f7LOd5/uc5PX19fbrqqqvO1JiyDUj0OLZjQtmGFKwTsBsLyzZElzGjkEErDPATcQlW4PeSbRlK5+N+rMdvAuqTNdJvxHNYjv0bbVwNtRPjiViEZ/E1dmEn3hQdON1n8zJuJwaF9bNWGOB3ipt4oGxDcmgprsJU/Jgzz104BIsbZFMetRPjC/AwTsI76MdqHINH8Ax6UnnyMG4nBoX1s7IH+JGYJRptV8m25NF1wuYDcEXOPO/ic1yGfeqst1fM4tPryNtujL/E2TgMF2MJFuAofI/zcG4qz1CMy2DQq/42K6yfFT3AXxE3lW6AHqxM4lYMCF+QxD1dUHmN1jp8ldQ7HD2Fw0Una7bajfGreAH/pcK34cHk//SMfLUYtxuDwvpZ0QP8JtEwyw2eSe/GfLH0umVA+Cz8i7cLKq9V9VZynV1C3Z3E+O/k+k9GXC3GncSglioYFD3AP8QTOBrzkrBbcb1YHl0+IO0Escf4THWnx3DKa2W9l1xPa3K9ncR4LC5N/r+cEV+NcScxGEoVDMY2oJKluBB9wqN3B9YIcAOXXYeK2XJrQeW1snbiT7F8aqY6ifEK4Wh7SdiWVjXGncRgKFUwSD/BN4t1f95fluv+B+H5PEK4+jeIvc1fqXQTk+uvQxidt7wsFXE/RekXHJwj3WaVdj2axK3LiFtZo6xOYbwYNwgn0rwa6bIYl8Wg3jYbqQYxSD/BvxEzQF79VCX85wH/F+KPjDR7vJnjctSTp7wsFXU/RWi8fB7cfhyUCpuKc/CY6EwDtalGWZ3A+Erci08xU3Tgaspi3AwG/Yprs5FqEIP0AJ9ZQAUXCefENvFe7hrZrv7tyXViRlw95WWpiPspQmNEB/g2R9r+jLBe0VlW4rVh1NvujK/FPfg4qWd7jbTVGDeDQX9GWK/62mwkqmBQtJPtTDFjfYJjxZJqkXiHmdZWMWNOKai8VtYU8cplU5PrbWfGN4vBvQkz1B7cVGfczgyGqwoGRQ7wU7BK7GXmCKjLxCoh6x3ibrwh9guTCyivlTUtua5rcr3tynhZUv9G8eTekSNPNcbtyqAeVTAoyot+HF4UXrzZ9nosV+F9sVQ5VZytHajV4mTSGeLc8UjLa7TmJj9iGQcn2+s02YEbM/LNEe9hn2+caVXVbozn43bBa73s46ebVTqqajFuNwZzFdTPegr4XHSy+BBgP5yOj1Lxs7BWnCuelorbF99hizh7PNLyGq0+3FYjfgsmpcIOFPu6NfY22nDVK7yyMwx/P9dpjOF1g0+zDcW4DAa96m+zPgX1syIG+Ei1RHwIcDw+KNmWRuhq3CcOHzT7SbBHXcajlEErDPBx+ELMoGeVbEvRGi9eI20QnwCWpS7jUcqg7K/JiHeo88Sep9M+xJ+Eh2Tvl5qpLuNRyqAVnuBdddVVg9QKT/CuuuqqQfof10P9i1ie+1QAAAAASUVORK5CYII=\n",
      "text/latex": [
       "$\\displaystyle - x \\left(x - 1\\right) + \\left(x - 2\\right) \\left(x + 1\\right)$"
      ],
      "text/plain": [
       "-x⋅(x - 1) + (x - 2)⋅(x + 1)"
      ]
     },
     "execution_count": 70,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "e1=(x+1)*(x-2)-(x-1)*x\n",
    "e1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 71,
   "id": "86a9a0b2",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAB4AAAASCAYAAABM8m7ZAAABH0lEQVR4nMXUTyuEURTH8c8w78DC2t6LGM3KxoIssWCnpCyUUk9WdrJiYWFhKwsRGxIrpSwkiZoskKSsKH8XzzM1PWaeGXVn5le3ezr3dL73nnO6uSiKtEMdAXN1YQJbuMEbXnGC8TQrHxA8jBU84BB36MYg1tCfxPyEBl9jADv4rvDP4RRDySU2CVvqA2ynoPCI1cQulJ0hwVn6SPbPVoLzGE3svVaCF9GLXezXApfEU9fo2qgDncIMrjBSeZCe6lu8N/gSuM84m8QyLlHESxa4+A9olqaxhIsk51M6oBk9nk2g5+irBm0GeF48TGfilz7XCgz5c41hAV84Fg9WWiWshwb3JHunuMfVdFQGhyx1hFydVSgHt+rL/KO2gX8BqMlAi6EQwO0AAAAASUVORK5CYII=\n",
      "text/latex": [
       "$\\displaystyle -2$"
      ],
      "text/plain": [
       "-2"
      ]
     },
     "execution_count": 71,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "expand(e1)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "49903554",
   "metadata": {},
   "source": [
    "* 提取因式函数factor"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 72,
   "id": "7d707428",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAJAAAAAWCAYAAAAvrxV9AAADIElEQVR4nO3aTahUdRjH8c/NIBca0ULurgiRgtILtrDU8C2jXChixIXSC7YoXPhCQpbBCIqCBhcDCVp0s9qEi6I2hWYgmJCLq1EUKbQQDYygFyKktMVzhobDzL1nzjkzZy6dL/y5M//znP/85n+feV7OOUONRkNNTV5uK3j+NlzEb8n4EuuKiuoDe/CV0HwdH+PBShXNUIo60BW8jMV4GJ/jQywsuG6vWYFjeBSr8DdO4u4KNc1Ibi94/kep96/iRTwiItOg8kTq/XP4FUtFNKrJSNEI1MosjGIOzpa4bj+YK/bil6qFDAib8AbOiDR/C++1MywageAhUfvMxu/YgK9LWLefjGMS56qVMTDsxSL8IcqU+zsZlhGBvscIluBNHDezCtLDeAxP45+ca4yJX+mKciRVzk4swJ2iJOlI2oE+ExuxMTU/hInk2KHUsRu4hPOiu5nEjq4lFyeP9texGavFd6iKPNp7yWn8kHzulKQdaDduYr+oaZocwRa8Jbqu6dacnVVpiXSr/SiexUp82yeNnShj3ysh7UAX8C4eEJ0JvIJd+AAvpOwPYTnuFbXQQRHG3++J2qnpRvsxkXZGReE8nIw5fdKaptt9HxjaFdF78QwaYkMP4FPxxW6mbIdFdT4s2uCLeDKxr4Ks2pt5/VTq/H3JuVXQzb4PDO2K6CuiK7lHtHJnRW6+0cZ2LLG7A/OwRjbn+VHk16yjbQtZQPtQh9HIqf3t5NjpNscmStaeRU8Ze5mJTm389ZbXW/FnmR+Ky/irC/urXdj2Wvs47krNjWA93hH/0FYmu1g7j/Ze7uW0tHOgUVG8/SRS03bTtHI5WF3yek36oX28zdyYcKAJfJFz3bzae7WXmUinsKfEr+gbcT/rOzxvigtJA0StvQJaHWgZTohcvFaE09dElOrnNYg81NoropnCFuET0Uk9jmvJ/AlxgXC9aNfP9FtgBmrt5bMhGUQ6JW6QTySvf8ZLRASaLzqnW+Iu9eXUYnuSv4d7obQgtfbeMCIuYG7x35ML97XMbWoaDtVPJNYUoczHOWr+h9QOVFOI2oFqCvEvExf5O6VZacsAAAAASUVORK5CYII=\n",
      "text/latex": [
       "$\\displaystyle x^{3} - x^{2} + x - 1$"
      ],
      "text/plain": [
       " 3    2        \n",
       "x  - x  + x - 1"
      ]
     },
     "execution_count": 72,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "e1=x**3 - x**2 + x - 1\n",
    "e1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 74,
   "id": "a2be3615",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAI0AAAAYCAYAAADH9X5VAAAD+0lEQVR4nO3aW6gVdRTH8c8xHxK7kQVCYBKRBVGH6sFuYuUFekm6PAhdJIMSulAUdMLgEF2EiqTIoB60y0OFQpEvdsEoCkmjE12hIrtaGkZBJVHaw5qD05zZs2f2ntnnsNlf+DOb//z3mrV+e82s//8/e2h0dNSAAVWYNtkO9Dkj2I7fsQev4NRJ9agGBknTLAuxDufgQvyD13H0JPrUNa2S5hnsxswe+tI0Z+IAVpYYW1f8S7EeH+MjXIVjcW6XdpumUKu8pDkLV2IN/mjOr1q4HI/hbVECDuC5FmPfx0u4F4cV2Gwy/sOF5ntrtluG2rTKS5r7E6NP1OBo06zGjRjGDyXGP4DZuLlgTJPxr8UYtjVgux21aZVNmpOwCC/ir65c7A23Cp+PwKoS49/D57geh+ScbzL+B7EAV+DfDr6/QjwdFnZ4/dq0yibNtRjCCzlGXhVOX5rpH8KG5NyaEs7UyVZ8kVy7LM9jjkiOLEXx07kGD+NqXIQvK/haJ7VplU2aReIuyHt83oH9os6lM+8hXIOncGcFhyaLd5Lj4pxzRfHTmQaPijnSBfi0M5cnjVyt0kkzU9S7z+RPAD/EszhFrALgLtwmHuc31Odro2xPjgsy/e3ip7oG60RZWS4mv7OTVjQRn0rkapVOmuPE3bOrwMhq7MOomFTdhy1CwP01Odo0v4kY5mT6y8RPNQ1WiRXTG4nd8XZ7x973llyt0kkzKzn+WmDke7ECOF4s394V9f3vEg7sFPW0bGu1HKyDvTgm01cmfqppMNSijba5xk4T9VifnNuac25DG3vdMEGr6anP46uFQ9sY2ZP6vBJ/lrz4VyJry/JjhbFVmWHi6qhs/HSuQVnW4qhM3zAuwdMiqdKM1Xz9NBO0SifN7uQ4S2uWi0nfT6I236Lc8o1YOUwFpokf5OtMf5n46U6DsqzN6VshkmYD3qz5eq3I1SpdnnaJO2heCwMXiyz/BKeJNfx1OLlmR5tmnigRY5n+dvHTPxqUJVerdNIcwFuifp2Y+fJ52Cjq+RIh7t3iSdXrvZlumZ8ct2b6i+KnvzQoS65W0zODNuEy8aJtfBPqdGwWM+nFDq4uNmKHeGSeL95p9JplSSNKBZzt4MTwFxNXKkvEXszLOfby4mdqa1CWZWrSKi9pfha7l4+LO26LuAuXislsmhG8JrbI5+s9w2JTLc0JSYNv/F+II4Vwm/Fdjr1s/Ex9DcoyrCathnL+uTciXtqdgQ9qcHYqcZPYoV2g9VOhn+OvQkut8t5yP4JvcU/zfvWUGSIhNikuI/0afxUKtcpLmn1id3OH/voT1lw8qf1ubL/GX4W5CrTKK08DBhQy+I/wgMoMkmZAZf4Dh/srWCQO868AAAAASUVORK5CYII=\n",
      "text/latex": [
       "$\\displaystyle \\left(x - 1\\right) \\left(x^{2} + 1\\right)$"
      ],
      "text/plain": [
       "        ⎛ 2    ⎞\n",
       "(x - 1)⋅⎝x  + 1⎠"
      ]
     },
     "execution_count": 74,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "factor(e1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 75,
   "id": "d98a74f0",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAALEAAAAaCAYAAAD48r3oAAAEnklEQVR4nO3ae6gVVRTH8c9Vg8Ai66+INKigB0EPQqWnGlYUkUQSSda1IjIiLO1hpNyiKFLjmqRGhVrkHxVFFkEvLNOKDLPAXhRJCJFWVlhmL/tjnYuncc69M2fmes+5zBeGc86ePeus9dtrZj9md3R1damoaGeGFLx+NtbjV2zDSzihqFMVg5rSc6ZoEo/DYpyGCfgbb+CQgnYrBi/jlJwzwwo6dF7i91T8gtPFHVZRkaT0nCn6JE5yYM3mTyXb7U+mYnftuHaAfWlF+lufwjlTdhJ3YyPeL9lufzESi7BjoB1pU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+NF7TSGiFeKxKx3dEqdrQ0cbAWK6vJN7XO99G663fWpp69Y85Bbl7SJXUU5rBITkrGicQczAxpr2bvYKoIpuEhMRgZ7Ag94rEU3xVfsYZRo0KPExpZNuG1APeo/WirWKonL43wx2fhZbBKaoZyXRK1IS8VajYkr2p5qTFzR9lRJXNH2VElc0fb8B6HEvkhlVlu/AAAAAElFTkSuQmCC\n",
      "text/latex": [
       "$\\displaystyle x^{2} z + 4 x y z + 4 y^{2} z$"
      ],
      "text/plain": [
       " 2                  2  \n",
       "x ⋅z + 4⋅x⋅y⋅z + 4⋅y ⋅z"
      ]
     },
     "execution_count": 75,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "e2=x**2*z+4*x*y*z+4*y**2*z\n",
    "e2"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 76,
   "id": "896a4307",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAGEAAAAaCAYAAACn4zKhAAAFBUlEQVR4nO3Ze8zWYxgH8M9b2SQtlDGHnJr8YQ5jZQ4pHRhzmJg5VJQ5j1JJpvYy1BTlUAjrxWZYoYk5V5RDKTlmlmm0SbXIoojyx/V71uP3/n5Pz/M+r7fk/W6/3c97X/d1n67rvq7vfb81tbW1mrFt0WJbT+B/gpFYgF+wCi/h8IKw2QhNg+6YjONxCv7Em9iD6o3wJFaiTZX9/NdxDDZjUI78VEzF5/gM/bAnTqA6IxyLSzAWv1bRz7+N9rgcL2Ap1mMt5opNa4xosBAv4g7sWkb7tsm4a1Q5gbtEjHuoij6aAufjUXTFh5iI6SImP4bnUNMI44zB3ri+jLYTsRgf0HAjHIpeYgHrG9hHpbhUHPnuFep9jbOwHy4WSXIgDsP36ItzG2F+8/EVrkTLEu3GoZtwjr+ob4R5YqF535yk3UDhPc/mDPR60j69uBrUJbKxJZfUeHhbsJFNqfoVeDj53T0lGyrmODSnz874He+k6p9BR+GgWbgH/dFThEbQKtXoBbyRoX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b1uKkT9eAUJt1TygXG8RFp4dgVtvz/xTKRUex+YcIz/4CN5WhdyCmqPzSiOqMQLCk9EvifxmnCQLys0iug5V3wVwim8yUhWqNsKNhSvI1KZr/0b8doNkI2wGajbAd4G8uOB/dEhz8vgAAAABJRU5ErkJggg==\n",
      "text/latex": [
       "$\\displaystyle z \\left(x + 2 y\\right)^{2}$"
      ],
      "text/plain": [
       "           2\n",
       "z⋅(x + 2⋅y) "
      ]
     },
     "execution_count": 76,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "factor(e2)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "19f1478f",
   "metadata": {},
   "source": [
    "factor_list函数，可以获取一份因式清单"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 77,
   "id": "cce30ea7",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAPAAAAAXCAYAAAA1FMKoAAAGvElEQVR4nO3cfawcZRXH8c9tMQGvSk1JNCpYkYB/+FIjoWpEagRMMCpB+UO0UIGgCMFWRMQALkalEYQqoIAS1pcQNVQkoPEtlmqLLxVEI0oUY1UUqI2IRlAQ6h9nNp3OzuzMzuzs7tX9JpPZzOx55nef85x5zvOyd67T6ZgxY8bCZFHB9c9hO+bHqCWPldiZOu4a8N1p0VyVl4i/6aQxPW+h1c//EmW+3sfu7XxnVfu8AD4Yb8U6/DN1/U24DN/H35MCv1D1L2jIJlyAywvuF2keN8PU0W34Kj6EJ7Wsa1rqp4ylOBk34G48jAexWTTeog5nnNTRWObrh0T7vgC/H8Y+72EfEY3vU5nr5+J0LMefcuza5BZ0FAdwkeZxM2wdXYin44wWNTE99VPGsfg0VuBHWI8NeD4+gy9jblLiEupqHOTrh0T77mBbwXNz7bMBfCAOT0Q8nLm3Nrn/FJxa8JBJMEjzuBm2jn4shgVvx+KWNI27flaLzGNlDdtf4/V4Ft6Cc3Ainoc/4o04ZhQiG1BXY1Nf59pnA/hE8fb4Uk4B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6JoXWwU5Gm+Di8Xu1f2F2PfLBeKBf4eo9B6tOHr6Eix9npjTnmj0FTk0xfhZjHBc4RdM9XX4yciDT5U7OseFyeIpb3HkufmbTvcJn8ybAtOEXuF1xo8Fm1Sr000DvJ1Ffrs8wL4frGedUXm3nIhPs3+yUFsws42zhfgHyKVbYus5kV2rZMdkhxZtusP6lFoXW64OtpbBPzNYhtellFoyvPpAWKpY6cI7N9mbM4RG2AuUrxBog2ek5wXi/FlHpvkB0dvXLgV15Q8p0m91tVY5usycu2zWykfETNqh+DFmXsdkX8XHcsy318ixlRXandpKqv5cTy5ROvTWtLaKXnussz3jxcTbXnj81FpyvPp3SJDeKr8DQ7fSfTWCd5uYntLDduOwfU3p3ib4lnC92UTV0s0q9e6Ggf5ugq59nm/RroUf9B8l9KhYpH9koblwAcM/j1wU82j1FqVvURPt0F+mjpKTaPy6bRyHF4n5jq2lnx3Gn2d/j3wYcPYZ1NoYqfHKjGzNq/+tsqbNF9T3mb3dduiyYKmmkehdViW4WrFmxtGqWlUPp0m9hOB+1zRO92J91awm0Zf934PPLT93Oxf6sxYoJwiZpz/Jsbra/DnCeqZCHk98IwZC4Grk+P/mmn4FyUzZsyoySyAZ8xYwPwXAiD/WdMeUQcAAAAASUVORK5CYII=\n",
      "text/latex": [
       "$\\displaystyle \\left( 1, \\  \\left[ \\left( z, \\  1\\right), \\  \\left( x + 2 y, \\  2\\right)\\right]\\right)$"
      ],
      "text/plain": [
       "(1, [(z, 1), (x + 2⋅y, 2)])"
      ]
     },
     "execution_count": 77,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "factor_list(e2)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "cdd914e3",
   "metadata": {},
   "source": [
    "* collect收集表达式中公共的幂，比如："
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 78,
   "id": "42ea482f",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAQYAAAAaCAYAA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rFgVYQAAAAASUVORK5CYII=\n",
      "text/latex": [
       "$\\displaystyle x^{3} - x^{2} z + 2 x^{2} + x y + x - 3$"
      ],
      "text/plain": [
       " 3    2        2              \n",
       "x  - x ⋅z + 2⋅x  + x⋅y + x - 3"
      ]
     },
     "execution_count": 78,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "e1=x*y+x-3+2*x**2-z*x**2+x**3\n",
    "e1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 79,
   "id": "ee0bda1e",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAARAAAAAaCAYAAAB/5gPHAAAHy0lEQVR4nO3cf7AVdRnH8dcFmjRUmjC7Y2VmP+SPSkYpsAw1VMqmZCqn0ULvUFmGFoSlVNq1saS0vGlqWY2Y5ZQjmWWOlkqaUEkaUZpZTVSkhARZmqYS/fHs4R6Ws+fsnp/3MPue2dm5u9/dfXY/3332+T7f59yB4eFhJSUlJc0wrsXj52MN/pUsP8UbWzWqCyzGKmHzQ/g+XtZTi0pK+pBWHcg6nIGDMA234rt4RYvn7TSH4RK8Gq/DU7gZz+qhTSUlfUerDuQ63IDf4358DP/GwS2et9PMxuX4DX6NuXg2XlPnmK9jAyZ23LrucRC24l29NqQJdkY96DNNWnUg1YzHcdgNK9t43m6wu3gWmzL2T8M7sQSPVm2fjHfjWvwBj+Fh3CE6QDufbye4S0SM5wjd+oUsPcYib8NF+IkYMm/FN+q0HwuafAa34K+iT2/CL/EJ0ee30Y4O/nI8gv+KYcEc8VXvJ0awGj/L2P9pIf6lqe3H4iuYjp8n51km8ilfxdUYaLexbeZcDOIDvTakAFl6jEU+jlMwFX/LeUyvNVkoIrsf4Qv4phjmD4uc5/MrDdvhQH4nHs4MfEmEls0kJIeEdz6sDTYV4TzMFM5gS439L8URwhk8ltp3P96M5+EdIjk7D1OE934r3tIRq9vHnbgP7xVRZFGGdFe3enp0giGt3d9CYfMeODnnMa1q0ip7i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Hu65dFjpfjSViKQL4pIbL7GMyEjNbYNaf3+miGvJp3oP1n8WXwcp4rIaGN6CHO08LT3iN+z3CcqLad0z8am6YTtD4ov4/4N2p0unMdqMauT13l0gokisX003q+x8yDub0Dnv6i1KKJbHj02iyTrNJHUn4Uvi9C7n+ilJvXYO1lvYfscyCHiq7UORwmhzhRRSrp+YqzRKdu3ipqBPfHijDZnJte4S3TWjS1cr1UmibqKQ8WXM2+lZuVrnZ7e7TRFdcujBzGd+wzhODaKJG2/0StNphidlaxmnEhu7yWivM2MDmEOwPUiwXSk0Sz3NaJA7Bi8VtTzjzU6bfsyUVE6247FZieKKdEtyflrlR6v1flkW4WrxC+M7xQJr+Eabc4VxVTVHCXu4bpOGpeiWd3q6VFhBU4SMzoL5ctFdYo5ycLoi3mw0T6xUQwz0/RCE3i9mPK/XeRX/iFmYg4VfWo93lNpPEF48puEd5+dHFTNYlETf57sAp1e0Q3bl4kk0gliGrSaFybr8bKrb2/THQcyzmjNwKuSJc0GOzqVSaKDXy/qebpBK7rV06NCJW+wCl9rg72tMFV8aKrZL1mIvELagfRCkwo34zLxy/QDRB7mUZE8vVLU0WxzyAPlfyTLxWLxO4AD9d9YuhGnik4x09iMMGvRSI/viQTyDKMFWf1E32gy1n9uPla4QJSBpys4+51dxcu4zBjvqCnq6XG8KLm+VH86j77SJKsOpGR7HhdFYYeLWY6x/j8o8rKvCFeX9taMwqT1mCwcx4vE0OYefKRn1rXGvvpIk3IIU7IzcJKYcfmnyJ0s0FzBVElBygikZGfgsmQp6TJlDqSkpKRpSgdSUlLSNKUDKSkpaZr/A6USSVLIa4X9AAAAAElFTkSuQmCC\n",
      "text/latex": [
       "$\\displaystyle x^{3} + x^{2} \\left(2 - z\\right) + x \\left(y + 1\\right) - 3$"
      ],
      "text/plain": [
       " 3    2                        \n",
       "x  + x ⋅(2 - z) + x⋅(y + 1) - 3"
      ]
     },
     "execution_count": 79,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "collect_e1=collect(e1,x)\n",
    "collect_e1"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "45e58d45",
   "metadata": {},
   "source": [
    "结合coeff查看系数"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 80,
   "id": "24f610bd",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAADIAAAAWCAYAAACCAs+RAAABz0lEQVR4nN3Xv2sUQRjG8U/0KhWxFFEJCmpnCiHaCSLYiBbapNBUgmhhiD8aCdfZiRBFFIInpBb8CyKaaBFQEcTCwghWEvyFKCKoxczhOu7l9lZvL8kXXgZm3tl9np15Z3f76vW65cCKXgtowxGM4wE+4Scm8xJrFYoqw0XsxGe8wY5WiVWsyLDwJPeWmDuCbViLkwslZo2MxhuOtsjdjm+4X0JQWabwUtC1IFkj07Hd3SJ3HCtx+p+kdYmskcf4isGcvKPYj2t4VoGujska+Y5ZbMKGTP9qXMZbjFUnrTPSYp+JbXZ7jWEjLuBjm+vNCfs5G7fi2FTOWKOc7L9Jj9+mkUHcEY67ETzC7QLXu4J1Sd8ADsX5c8nY04I625IaeSg8qeaKXBUK/JQCJ4dgJGVYMNLAvc4lFiPdWu/xArswhH24gSfdEvC/yHshTmOVYGBeeLsuevI+UWZwAmuE+nhXqaI/ORwD1sd2j9+HxDzOkm/kVWxnMdENdR0wgONJ35YY8Fo0kre1zuGH4gXejgb6lCv0epzbKvqbiamRIRzEdWFFlgw1bBYMbMUxPMf5XooqQw0HcAkfcBdn8KV3kspRw80YS5rF/qtbmGVj5BcXQFY5NiZ8RAAAAABJRU5ErkJggg==\n",
      "text/latex": [
       "$\\displaystyle y + 1$"
      ],
      "text/plain": [
       "y + 1"
      ]
     },
     "execution_count": 80,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "collect_e1.coeff(x,1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 81,
   "id": "87cd299e",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAADMAAAASCAYAAAD2Uea5AAABz0lEQVR4nN3WT4hNYRjH8c/MXKUkC4vZKdbWoyw0migpC3+WzPiz8ScpSil12JA/ycKwsJA0K9MUESmasFHKQpKoyQJNUlYIw+I9t463c+99T3OdpvnW23nu2/P2/n7d53nO6cmyzHyhtxAvxR5M4C2+4SueYHeUOydpFOJtuIyPeIT36MdmXMWGPOdPzRqTKZp5g024g5nC/jE8wxbB2Hht6ipSLJ2HuO1fI/AJV/J4sAZNMU+Fami1JpuJjbLTJfzMn7+6pzGZCTwo2d+JZUJLIM1MAzvy+N6spVXnXMneWcHINZxsbqZMqNNYibu43wVxs6EHoziCS9il0BadzBzEYbzG9oTLprSv73jdSLZBn/BP7MUZHBBN1nZlth8X8QpD+JJw4Tt8ryDwQ2LeAoxhKzKcKEtqZeYQLuClYGQ68dKhxLwqLMRNbBTK63yrxDIzR4U+eYF1+Nx9fckswi2sxT7hpd6S2MxxYTo8x3pppfW/WCIMnVUYwfVOB4pmhgUjv/FYaP6YKaEJ62AMq4WvjxVCr8Scwo/mj6KZ5fmzT+iZMibVY6YXa/J4IF8x0yKDxdGcCXO83Rrsnt62zGBxBy398aE5/1lfhXll5i99KmMYhrMT3AAAAABJRU5ErkJggg==\n",
      "text/latex": [
       "$\\displaystyle 2 - z$"
      ],
      "text/plain": [
       "2 - z"
      ]
     },
     "execution_count": 81,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "collect_e1.coeff(x,2)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "53dd237c",
   "metadata": {},
   "source": [
    "* cancel函数，消除共有因子,分母同分合并"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 82,
   "id": "6fd1bfb2",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAE8AAAAmCAYAAACFz8YUAAAC1ElEQVR4nO3YS6gNcQDH8c/VlQU2XtlwLSzVtZCFV9wSyuJ6xcItZUXKxoYs7oIkKY+SnddONxZeN3lGUsgzFtgQiqKQImLxn5Pp5J5z5szjnqv51jTz/5//+c9vfjPz///n19bb26ukOYYlaDsJ1/AUD7E8D0FDifYEbX9is2DcBNxDP77loGtIkOTJeycYB+/xCeMyVzSESGJenBkYjtcZaoGtuIPP+IAzmJbxORphXnTut/iNlf9q1Ix5Y3Ec66OO63EUvQ32PR+HMAtdwlBxCWMSakyrY6Twlm2q1Shu3ip8R0esbj+eY3xUHoHT2IVbDQpJwiIcwRM8Rk907tkJNGbBBWzHqVqN4ub1CYK3R+UtWIPFwivUJty9KziRodBajI40fmxQY6HEZ9vf2IZzeBkdd0XHhLu/Go/QHdX1CBeTF/vwALcb1Fgo1UuVi8KAvQNLcTf2202NjZHboq3CCOGit8TqluBGnX72CAP3XPxqUGMeOgak2rwudAomvW+yz8M4GSvvxhsciNW9qdPHXqzFArxoUmMWOmoSN69TGCA3Yhl2CncmKR/9HaPgS1SuNmEgDgjDwwLhayZOEo1pddSlYl4HzguvyjHcF8aauVI81k1wSHjiuoULnRjVfxWWSEVpHIWpsfIUTI80vapUtgtrqH6cFe4kYVLoE5YkczIWVosN0f5yVf1BLFScxhm4GivvifbHsK5S2VamKs3T7OdZidK8VJTmpaAy2zbygV9SReXJaytwm4zreCbMmCsKPn9mW5IkOSv+m0R6MMa8/yaRHuwJI69EuhAG07w8E+lCyMO8VkikC0mc8zCvFRLpQhLnPGbbVkikC0mc8wwGbmGmkPb2N/H/gZLgH7G6eklwWg01yWud1wqJdBYaapKHea2QSGeloSZZm9cKiXRhGrKcbesl0kVQqIYySU7BYH+eDWlK81JQmpeC0rwUlOal4A+MKulySQZJ1wAAAABJRU5ErkJggg==\n",
      "text/latex": [
       "$\\displaystyle \\frac{x^{2} + 2 x + 1}{x^{2} + x}$"
      ],
      "text/plain": [
       " 2          \n",
       "x  + 2⋅x + 1\n",
       "────────────\n",
       "    2       \n",
       "   x  + x   "
      ]
     },
     "execution_count": 82,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "e1=(x**2+2*x+1)/(x**2+x)\n",
    "e1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 83,
   "id": "2a7a44b1",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAFYAAAAVCAYAAADcmhk1AAADZUlEQVR4nO3Za4hVVRQH8N+ohGJkoFBQVIhkfqmhBxTUUKFTFJFjQgSZkkEFPSgMNAyGKBMKkvoQ1Iemx4cKpwcZUUETRRI9yD6EQUVRhvmoKMgkyOnD2oOnfc+5c+6Z6XYD/3DZ56y99t5r/fc+a6+9b9/w8LAjmH7MqJA/jb2Y20Vb/m2chXGs7cZgZcSejWuxGb93w4gpYCUexXv4TRD3bIXuJ3gZ9+HoSfo9Dn/hkaaGlRG7SRj5WNNOu4iNuAX9+KGG/gM4HrdNonel4OalpoblxJ6KpXgBfzTttAOsEavswobt7xA2H4Oba+h/iC9wI2a20RvCT3i3oV0txF6PPjxfovumIGFFJu/DSKrb3NSQhhjDl2nsungOJ4kFVIZ5uBivinAwgY78z4ldmjr7oGTAu3BIxKjibD+E1XgC6yuM7SW8n8plFfWX4yi8mMk78r9I7FwRq3Yq37Q+wzNYglVJdjfuFKHjpjbO9BI+SuVARf2Q8P+tTN6R/7MKzyeImdjdxqiNuBrDYme9H2+kgQ61addL+BUHRTjIMRuX4vWkk6O2/8UVOz+Vv7Qxahe24GSR5mwXMefPNm0m8K2IQ8Xfk6lurKRupEafTfEzFpTIBwVhVdlAbf+LK3YiC5g9iVH7Cs9rcWAS/QlswbGZrF+kNk8J4ovYUbPfJpijPOsZEiS91qZtLf+LxO5N5fwyxYRrRLD+UeSDt6uX5hDE5lgjiB3BOzX7mSpmiAn+JpPPxBV4W4SLMtT2vxgKdovZWFzR6WViZX2O00U+eANOa+tG72GxSJF2ZPIBsaiqwkBH/heJHRcJ8QIsyvTOx1YRYwbFBNwjVny3c9ep4txUjmXyFWIDeqWkTcf+z8reR3EVLsFXSXYGtonPY5nDWcNWfCw+5QvEeb3bWJ5+xKcJ5zm88e3HuqzNoMjVcwKXi81oTyZv5H9+QBhNHV+X3heJdGJckP11pr8hlQ/6b9AvkvPVwj5YWJCtzPTnCQK34fuC/BycqDUMNPa/r+Q+doO4iDkTn1Y49H/FreLGasA/V9gm4fdCrZtaI5Tdbj2M73DvdAzQQ5gjyBvVGraGxMlqWkilNcYSJ45VuEgcc3v9TrYuTsHjyg8eS6Z7sDJiieyg8ZVZj2KnOIp2BVV/zRzBFPE3vS/Q9fMo5DAAAAAASUVORK5CYII=\n",
      "text/latex": [
       "$\\displaystyle \\frac{x + 1}{x}$"
      ],
      "text/plain": [
       "x + 1\n",
       "─────\n",
       "  x  "
      ]
     },
     "execution_count": 83,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "cancel(e1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 84,
   "id": "e0261e50",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAHUAAAAgCAYAAAAsRzf4AAAE+0lEQVR4nO3aa4hVVRTA8d9ohJBRWaIfgiLCCrKEkjTSTOhpMY6kJSUJJlh96IFBmcV8SJMepCXSC9QeFBGl9C5fFFmRkJVFktFL6GFZ9qKksg/rXD1zPHMfZ+5cZ8b7h83cu/c+a+3Z6+y11177trS3t2vSt+iX+nwNPsSvSXkbEwrKfQT34ma8l8jbhudxYtHBlqFRenoFaaNuxU04BadiDVbgpAIyL8RKjMMSnI7x+AerMKgLY86jUXp6BS0V3O92sQoexGQ8jmH4KmlfhAvEZG5L6kbjBQwRk5tmIHZgolhN3UWj9PRI+nVS3x9TxeSsT+qewUeYm3yfjUtxnj0GhVa8aG+DwsGJzu1dGnVlGqWnR3JA5vtwsZcOwG/iTf8oaduFOcJgnyefxyef07Tilk70LcRGvNOlUVemUXp6JNmVuhkjMAoP4FEdA47XREByO6ZgQ+b5YTgar+bougtjhRv/t5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IbErV9RdnuVk4SOzpTXIoatRqLsxLFLn4XmHvlb9UBGLzNVdvWYoYNXth/r7IhY4Rv8epB78kJc0f4gJ8U7Zzk47UuqcOUt2FeZN9SK0rdbvqLsy7g3EN0NEn6C1pwiY10DRqH6Rp1D7I/8fQc30y8mk/AAAAAElFTkSuQmCC\n",
      "text/latex": [
       "$\\displaystyle \\frac{\\frac{3 x}{2} - 2}{x - 4} + \\frac{1}{x}$"
      ],
      "text/plain": [
       "3⋅x        \n",
       "─── - 2    \n",
       " 2        1\n",
       "─────── + ─\n",
       " x - 4    x"
      ]
     },
     "execution_count": 84,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "e2=1/x+(3*x/2-2)/(x-4)\n",
    "e2"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 85,
   "id": "4e1e140f",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAFcAAAAmCAYAAACxtgcIAAAD20lEQVR4nO3aWYgcVRgF4G8SRQnmxagEQX0N4hI31GhkZkBU4sPE3Wh8iSAoqIigRsFWIwZiIFEJvgSjvoiIW3AQEXFNBCMuMRE3IkYIRFFcEBWDPvzVmeoeu6un+1a6Z6gDl67l1r2nTv33r1v39FCtVlOhHMxK2NYxeBM78QkuSdj2tMRBCdv6B7cIYY/Ch3gVfyTsY1ohZeTuEcLCXvyMIxK2P+2QF/cmfIpfs7IVS7ps93QcjN09sZuMu/CB4PcDNuOExH10itl4ALvwZ/a7Si4b5MX9HnfiNCHOG3gRJ02x03l4Civwb3e8W2IYG7AIoyIVvY7DE/fTCe4QAXkzFoiUeKMIADSK+xLG8RW+xN34DWdn5y/HXzgud836rP6R2f4heAEPYUvSWwlcgCfwGbZjedb3Obk6nfBMgUV4WYyeb3PbZ9YrtMq5s3E1DjMh0nPihu7J9m/HVbhQDNEhbBIR/3SyW2iPueIefsodK+KZClvE6FmQ7R+f7Y/XKzTPFk4UufZQEbVjGVFiiK/EK/gm2x7NtonouVLk7bHs2PLc9WVgHT7G+7ljRTxTYbV4uDuxT2j5oEhbmBy5X2AhzsLjInfmXxiviRfKKlyBbblz72btLcyVVsLWhAjtynDBza3BeSIN7Gs6145nKh6X4Rosw6m4TuTcFfUKzZH7N77OtrfhDNyK67NjozhZiLi3Raed4DE8U1Dnuzbn1uJajJjgm0enPHvhsRYP567fLvL8Smyk+CNilkgRMrLPi6ezVAyBiwqub4Ufs9INHhHpZ0QMyWZMhWcvPOaYPGIa9vPirhZ5arfIJcvEkFginsi4GIpP4iOR6xbjnS7JdYMNImLHxEtsfnb896wcSJ6bxdR1F3bgFNwmUikYyi3cbBLRMB+/iBfTGpG73sPbuCHX+LM4GucmJt0OrebN94mIPpA854qPiKXic3+PSBH3i4+KBnErJEbKtYUKTajELRGVuCWiPltIvcBSwUTkDvWpHIu38LmYnVzaRy7JS0onohvMaPei3zl3RrsXvYqb0hkoy70odAzKQq/iDkvjDJTpXhQ6BmWhV3GLnIFBcC8KHYMOeU4ZqXNuszMwCO5FoWPQAc+ukDrvrNPoDAyCe1HoGHTAsyukFLfuDCzWuK6ZdwUu9v/uRSeo4d6COiPiXz955B2DHcIhWS9ebBs75NkVUonbzhnot3tR6Bgk5rkfKcRt5wwMgntR6BhIy3M/ehW3nTMwz2C4F0WOQWnuRa+L5a3mpI/ifIPhXrRzDOYo0b2onIgS0e+1hRmNStwSUYlbIipxS0Qlbon4D9YqUI29O36IAAAAAElFTkSuQmCC\n",
      "text/latex": [
       "$\\displaystyle \\frac{3 x^{2} - 2 x - 8}{2 x^{2} - 8 x}$"
      ],
      "text/plain": [
       "   2          \n",
       "3⋅x  - 2⋅x - 8\n",
       "──────────────\n",
       "     2        \n",
       "  2⋅x  - 8⋅x  "
      ]
     },
     "execution_count": 85,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "cancel(e2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 86,
   "id": "c2274b30",
   "metadata": {},
   "outputs": [
    {
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8MagJ/PAJuQquARxzkmm/Xez1LVjDbASuAK5jSn6/xX4y5MNLo0xNFQh91gXpIpl7f5HkPcmU4jwtaZ9JzIjt65n/y7wL4dP78biFmTW6z3kC4JiWUV9O1rAXcjzw5ae/s/zpN+lMYaGqnTJN9Y2XeLH0kv/g37buRl5oLxtkIMyZFjsCElTfNQUnYfRO+HSjxHk5eYK5POeZUEVhWNY7AhJU3zUFJ2lVEm+xciLwi+Q9yh7gyoKx7DYEZKm+KgpOkupknwdwn2AHZMOw2FHSDo0w0cdmqGzlMYboChNRZNPURKhyacoiSie+Xz/FktRFAdF8rWSqlAK5iE/PxlFPpN6EPkMTRlCqsx2KvE4gHwqZRfdmUILEw0l+syXF1qY6AhCky9fQhUmWowUI/oeedZfWr67EgpNvjwJWZjoaGR0vd1zv8qAaPLFxVU4CcIXJnobqR2jEzmJ0eSLi6twUorCREoidLYzLq7CSSkKEymJ0OSLzztIJeaHkcJJn1h/+5BqdyNt/BQmUhKiyRcfV+GkKvgoTKQkRpMvLq7CSVWpW5hIyQBNvnhULe4UmmOAU63tU5AS69PoaBkVne2MwyDFnUIzhiT+DrO93qw/FFnHEY+OfHGYBk7v056i9kgH/ZA+C3TkU5REaPIpSiI0+RQlEZp8ipKI/wBQHz+l0vR1xwAAAABJRU5ErkJggg==\n",
      "text/latex": [
       "$\\displaystyle \\frac{x y^{2} - 2 x y z + x z^{2} + y^{2} - 2 y z + z^{2}}{x^{2} - 1}$"
      ],
      "text/plain": [
       "   2                2    2            2\n",
       "x⋅y  - 2⋅x⋅y⋅z + x⋅z  + y  - 2⋅y⋅z + z \n",
       "───────────────────────────────────────\n",
       "                  2                    \n",
       "                 x  - 1                "
      ]
     },
     "execution_count": 86,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "e3=(x*y**2 - 2*x*y*z + x*z**2 + y**2 - 2*y*z + z**2)/(x**2 - 1)\n",
    "e3"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 87,
   "id": "0d42e5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JIpOi+EU/wJb2VE/Sz4QeLhO4NvRaSp1eGXypW/ubn9m3CZ2JGmYKXsRbPJYqXhF4Z/qzIWa7NtlfhcpwrsvV9S5UPgVIyIbItL4o15dUiS195fXm20cs+/FXxDcpdYjFqZ4Pzaoqz5PmyeHqlpqNXLZxo0SPiT9/X5LwUKbsZQ68MHxEvs5W4EHeLhG0RnabsZhS9MHw+XhJZ+cdFjnJMZOcbZcjb4RAcn9s+Tnw0NK6HT0S3+/B54mvSraJVw/ti1LI+cV0LxJ+5O9vekP1el7ieSnS7hY/jhIL905HBGTUDlyz6eaY5IxkY3mUGhneZgeFd5l/QMAzrWzj/8wAAAABJRU5ErkJggg==\n",
      "text/latex": [
       "$\\displaystyle \\frac{y^{2} - 2 y z + z^{2}}{x - 1}$"
      ],
      "text/plain": [
       " 2            2\n",
       "y  - 2⋅y⋅z + z \n",
       "───────────────\n",
       "     x - 1     "
      ]
     },
     "execution_count": 87,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "cancel(e3)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 88,
   "id": "f4e1ba14",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAADUAAAAmCAYAAABkpNNFAAADa0lEQVR4nO3YS4hcRRQG4G9GxYwK4vhARUlAN4ohInEhagxZKSKo8REkoDiahfEBIiJJ1DYogllIRBcaFz4QXAwKGh9xEQd8RTRkTFAQFUElJhrjQnwkEdvFuQ01Rffk3r49jw75obhdVeeePv+tOqdOnYFGo+FQw+BMG9AFzsQYvsIXuDYXOHKaDeoF/sU9gtAp2Ip38VdLIF+pE7AbZ02TgWUwinuT/s+CEPyC33FS+kJOapVg/d0UGdgN1mINjm8ztxBH4cd0MCV1DG7H81NlXZfYju+xPBs/ES9hBM10IiV1Jf7Dh8nYTyYuPZyPfTi3trmBBwqj8vZwIvMGbkr6R+N1PI6Pc4UpqUuE06WsP8GF2TtPYoOIPr3AMzgtaeuxC68kMp8WdgxhAC9gM15upzAlNQ87s/mc1FIsMPEr1sUfgsQu3IobsBjfJjI7he+cjotxI67GeNHmpwpTUnPwT/aHW0QkHBZL/oRw3N/aGNfQfhulbfEk5FZjZSHzdTb3d/EcEu4xKNyg1Xakwuk5tUeE9BRbsV9EmQtwQGyXdngar05iNPzQYfxBrMBlJq5QC8PF89eD6MdEUttwSza/rxi/CjcLZz3QQdeeolXFQ7hNrFCno2S+2IK7yyhMt98mnCM7yIRfrSyeG8vbWgqrcTeW4U+cWrQ5mdwicX6WQkpqh4gyyzKZcRHq89BeFwO4X5w3H4lModUuSuSGRFDYUFZxnlE8Ir7cEcnYcjyLLysafTA0RZYw0Ka9n8iNiIC1paziPKHdJBz+DBEJR3CeCLMzhf24q8oL7bL0p4TTbhahdalIGmcKz1V9odPVY0x/3rXQx4ZPhsOk+gUtn2pOKtVnaJEamFEreozZtv0W4U2R5zVxXTdKZhupY0VR5c46SqqQul5k7XOTsfX4BifXMSLBO6LI8lodJVVIjYqkd03Rv08kv5crec+ZLlQpZjZFCe0tce9ZhSVmVzkN1X3qPXyGR0WS+3kHuYZ6V/taqFp2XiIKL4OiOtoJda72tVGF1ALhwHfgGjyGKzrIdnu17wnKkpqLt7EOL4q6xTguxQc9tOc4nJ3054lq0V4VVraMTw2L+sBGsTpEKXhUVEh7iYXig20r+uuK32urKCmzUntFQSbHVNyGx/QgZZttGUVPcJhUv+CQJPU/+G+7S0j1iRIAAAAASUVORK5CYII=\n",
      "text/latex": [
       "$\\displaystyle \\frac{\\left(y - z\\right)^{2}}{x - 1}$"
      ],
      "text/plain": [
       "       2\n",
       "(y - z) \n",
       "────────\n",
       " x - 1  "
      ]
     },
     "execution_count": 88,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "factor(e3)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "bb457b33",
   "metadata": {},
   "source": [
    "* apart函数分解有理函数（哈哈哈这个太有用了）"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 89,
   "id": "175c17e7",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAJwAAAAmCAYAAAAx6fJeAAAFnElEQVR4nO3bWYgcRRzH8c8mXqAiaoz3gSgKKlEUT9YLb3xQUfTBPIlogqiIL4rKeiNRURERRVwV8YoHXpHgBWq88Qret3hLlHhgvOLDvxvHyW5PzUxPb+/SX2h2tqan+vef+ld1VfVvhkZGRjQ0VMW0kutbhDewGOeVXHeVbIqn8baI56gJVTOFWKnk+g7BUkzHs3gQr5d8jSr4C6eJZJuJV/EYfptIUVOBske4pdnfVbJjsvK1SDb4Dj9ixsTJmTqMl3BnYzmu7aHOF0UjPa780e0svCwS+3s8hO3bztk7K/9KxHB0n9fcBSvjiz7raSdV51x8gt/FSDtcso4UUrSmtM2YCbc7TsSbPYrbDRtjx7EuOA6jGEk4b19chz2xv7j1PY51Ws5ZXYxOpyReu4h1cStOEF90J0alxUGazmNxNS7BTngOC7BZ4jWKGFWu1n11bpsVEm4t3C6+4B/b3jsGy7B5S9nV+ADrtZ27FE+KOV2ZHIybxaLkLczOrr1XyzkLcA7uK6gnJZZVcT8uFYuhsknReYZIjBvxDk4Vt/s52fvdtMmgtaa0zQoJdwPmi2RpZ35W0TnZ/2fiOJFU34tkzYNcDQfh3ZRo+mBNEcOSLj/XKZYh0dBP4rYyhPbAKtgZC9vKF4pRhM5xTCRjtk3rKvVEbCUycyyWi7ndI/goe71/9hrWxr1ivjMNd+PhcrSPy1VinvhCl5/rFMte4nb2Jo7IymaLxq2KGWK1/21b+bc4IHvdKY6J5CpjtE2ecNuIecIw/iioZKGYGF6Ew/FKy3ufih6ZwtnZkbOq+PLObCk7FM8U1DFPTGaH8XfidVspiuVZaSv4MuLoRPvccaitrCiOqrXmjNs2ecLtIXrU4pb3pmcfOllMGpeJ3jNLNMZ3fQi6XoyAOZfhS1zTUvZlweevwPHYDx/2qKGMWPqNo4gfRGNt0FY+0/9HvdQ4B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x^{2} + 4 x}$"
      ],
      "text/plain": [
       "   3       2            \n",
       "4⋅x  + 21⋅x  + 10⋅x + 12\n",
       "────────────────────────\n",
       "  4      3      2       \n",
       " x  + 5⋅x  + 5⋅x  + 4⋅x "
      ]
     },
     "execution_count": 89,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "e1=(4*x**3 + 21*x**2 + 10*x + 12)/(x**4 + 5*x**3 + 5*x**2 + 4*x)\n",
    "e1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 90,
   "id": "50747f1e",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAL4AAAAhCAYAAABnRBELAAAGPElEQVR4nO2cf4gVVRTHP7taRllb2g+JxAgrrUgJBUsTMyp/FPosrShpwQT7AVGs0C5aa5QaW6AmEga5mwYRUpnZmrnrUhFB4Y/VJEpJy59Za5ZWhrX98b2vN2925r03P5z39s18YJidO/fOPXf33DPnnLl3K+rr60lIiBuVAdrWAl8CvwFHgLXAdWEI5ZHRpu8DQCdwTxFkiJo4jjlUgij+GGAZcBMwFjgFbAT6BBfLE+cA24DHI+63mMRxzKHSM0DbO2zX04FjwEhkjQCmAquAq4C9pmwxMAFNmCMB+k/TbI44Eccxh0oQi2/nXPO8DkvZamA7MMdc1wD3AeMIR+kTEnwRpuIvArYCX1jKOoE6oBp4GngGmAjsDrHfhO7Ji0AL8CPwJzKYW4Bngb552l4C/AMs8dt5WIrfgAKuqUYgKxtQEPw8MA34yuUZ9Wii5DrGhCRvQvF5EsUqHyP3900UJ9YD7UD/HG0nId1912/nQXz8NC8DDwK3ALsc7o8FhiBBf8rxnKXAW3n6+sGPgAmnjWpgBfrbt3lsex7wl0P5C8hLqAUedWmbAn4BPvHY5/8EtfhLyCj9Tof7Q4B30ADeR4Ny42fgmzzHHwHlTSgdnJQe4G1zvtLlfhUypmvJ9i42IK9giq1+BdBo7i1MFwax+MuQ0k9G/lk/U37cHAOAD5Eb1IT8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O3yxfMuGL9cpu2POuQtalDyz/TlmckWgfRjiJs0BqI7SHKk0+GcqXQPQuvklm2C9rFtJ/snUj7bW1uRH70DktZDxTrzEKu30lfUndj7EsWrJbnTrItz2cUFhPUmSNNL6TQNZay8bgvTc4lQ5j9lArWPQsplMce71K3g+zA73dz7bQBKM17dP0drkDu43xi+hawK36hlicXfqySHxmC9lMKRLFn4VdzWDmBJswOe+W4YFV8L5YnF36skh8ZgvRTCvQhuj0LCTbSih/VbqlcxG3HVgfB9yxU++x7jM92ZUMl+S1PFEQpwzA0qbaY6wbz83Mh95NQwlQk/zQ2IY4kO7ASYkmi+AmxJFH8hFjyH7Mit1pQGGxFAAAAAElFTkSuQmCC\n",
      "text/latex": [
       "$\\displaystyle \\frac{2 x - 1}{x^{2} + x + 1} - \\frac{1}{x + 4} + \\frac{3}{x}$"
      ],
      "text/plain": [
       " 2⋅x - 1       1     3\n",
       "────────── - ───── + ─\n",
       " 2           x + 4   x\n",
       "x  + x + 1            "
      ]
     },
     "execution_count": 90,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "apart(e1)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "300cd6b0",
   "metadata": {},
   "source": [
    "## 2、三角函数化简"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "df3caf39",
   "metadata": {},
   "source": [
    "* 表示反三角函数，在三角函数前面加上a，如"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 91,
   "id": "3907c07f",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAEoAAAAVCAYAAADhCHhTAAAEk0lEQVR4nO3Ye6zXYxwH8NepqFYpKjnIJa36A1HkshLKrbk0FsuQypiNbMZ00bRGsuVuY2wqZivKJf0hopRbqeSSEpYs1bo4IjpF5Y/P8+t8z/f3O+fYTmad+Wy/Pef7eT7P5/k87+dze07ZuHHj/E91U6P/2oD9SC9gE1rUQ0dP7MXw/ERDAeo0XIeJ+L0eep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K5SeTIy9P8MNXDfSauSrq+y/C7p/22Jf2FyjhDpJArREO7MI+SAHU33igwsn1UezycwGmGL/FMGpeJhjP/qu4jADtL5KItSX6q6O6z1Fck517pe41oZieJF0CBBqaD9xJgNxPAzhVV89uc3oOFl63FGYnXWYRp07RvPj/2F4VhkSrvKVBrkcuqvSzyDeeBSqNEf9ZDPInqQ7fjCVFA9nlbQ3gUw6PCq8bXJVgHNVf10qgWkg0FqErRZS9Rv3/cHYdncVd+okmR6IFLC9KvPrRSPHOKqKF41L9OfwN0KRZvgWPeeQAAAABJRU5ErkJggg==\n",
      "text/latex": [
       "$\\displaystyle \\operatorname{acos}{\\left(x \\right)}$"
      ],
      "text/plain": [
       "acos(x)"
      ]
     },
     "execution_count": 91,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "acos(x)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 92,
   "id": "35dad57d",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAA8AAAAPCAYAAAA71pVKAAAA+ElEQVR4nKXSL0tEQRSH4Wd1ox/AZjFo0S+g0RUsgkUMYtBgEwRBZYUbFBY0CEaLYpONFsVsshgEgzZBwWQxGHYNM+Bldi7CesrMOfN75/yZqRVFoV8bSPwbdLGQxGs4i2etKngLHexjsBQ/wgpOsV0FP+AC41iOsV1s4hLrZXE900oTiygwhANcx8s6ZWGaGV5xjBGc4E6YwXcqzMHwUdqv4isnysFLwoDeo79RkaAHnsM5HjGBJ6xh7C94Cm2h50YsfU8YaqsX/YUncYVPzOAtxtu4xzymc/Co8BRdzOIl0ezE9TCF63jGcK6saLfC96wsuy/7F/wDS+EshlnBurEAAAAASUVORK5CYII=\n",
      "text/latex": [
       "$\\displaystyle x$"
      ],
      "text/plain": [
       "x"
      ]
     },
     "execution_count": 92,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "cos(acos(x))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 93,
   "id": "f5e894eb",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAB8AAAAUCAYAAAB1aeb6AAACAUlEQVR4nNXWT4iNURjH8c+YSRZTQrKRUhZkyqVscSmR/LkjWWHBRkpKUUrdlLJQIsWCmi1hSP6lCJOFUuNvFoqk/Al1i/wbrsU5V+8c73vpuiW/envOfd7nnO85z3nOeW9HtVr1rzSiTeNMwDccwDhsQD8e4yNqGMD6LLOrTfDlcdB+rMIhvMBVPIuT68URLI4x9XbBK3iL6+jAMpzD90zMDtzCyjiRk9m0L0H9D59Spt9ozMdZIfVXYjsLhpc4HNvzGJ72mpCujXiAE5l3U7Fa2LfLuJtMeiROpenI0ddoh1L4AMZH+GlUM++2RXgfjiYDVvAhTqqZurA2ti/ya7WXoh1M/LMK/KOwCBfw6TfwPejBeVxqBr+TAx/C/cS/EN1ClTfTZmzFI6xpOPPg74Xz2VA3psSOn5P4Cr4IlV2kTdiPhyjjXR58DCYJxVTP+GcKx2cwGbQTS4XqrhWAt+CgkLGyUPE/lYWXos1LuRz4HOE2K0r5duyL/cp4nQbkwVNIT7T3En+vcJbP5IB3CgV2GwvwJm922aPWgKcrHxvtdGHfnsffK3ATr5L4ddglXDg3hGJL9RR9WfgMYSXpCo9jLnYL+7wXszFRSGuqydF2Cnuep2spvFQQeCw+WVWizdvvquEXVKFa/aRWhO150mJ/tP5JnfY30Iba9Wfi/4P/AN4rd9qGuspnAAAAAElFTkSuQmCC\n",
      "text/latex": [
       "$\\displaystyle \\frac{\\pi}{2}$"
      ],
      "text/plain": [
       "π\n",
       "─\n",
       "2"
      ]
     },
     "execution_count": 93,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "asin(1)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "75266575",
   "metadata": {},
   "source": [
    "* trigsimp函数,三角恒等式简化表达式(太有用了）"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 94,
   "id": "0a951a52",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAVAAAAAYCAYAAACslKVsAAAH6UlEQVR4nO3cf4wdVRUH8M+2JVLRFGkxGAgsCbHSoDSICv6oWwtUDIKikhjB1v4QqVqJilDTxlVrJWK1+DuiUlFINW0ssaI1SEVq/UEJVYsiaEDb0ipN3aJYlNX6x5nnTmff231v9u3M2zLfZHJf7ty599zvuXPuuefeeV29vb0qVKhQoULrGFe2AAk+iIP4XNmCVABLcDcew6P4Lk4rVaLOQcVNZ6AjbEYnGNCzsBC/LluQCv9HD76Al+JV6MftOKZEmToFPSpuykbH2Iw8BrRbWP7VbWh/Em7GfPytifI34a84Kmd7LxSyz8/5fKejW3t0Mxs3Yjt+g8twLF42xDNPFd1U3JSLjrIZZXugX8Za3NFE2TNxKa7F4znbuwfrsRzPyFnHSDEZC/Ad/AEHsB+bhZLK1kk9PFPIta/B/cNFN3lQcVMsOspm5HlZd+FUEQsaCRbiFCxrsvwKEXf64gjb/TiOw+IR1pMXb8INeAl+gVVYJ+JoX8G30ZWz7nbpJotV2IafN7h/uOgmD1apuCkKHWcz8hjQJ3E/do9AoKmic2/Bv5so/1ycI4zLgRG0C78U8l+O8SOsKw8ewIU4QfR/CebhediBN+DinHW3QzdZXIcZwvD/p879w0k3rWKscTNXLEd7RihLGehIm5E1oBfiR+IF/BcewZ1YlCrTbXCcLZ3XjTXYiyewFRdk2jkbU0QcqT+5Xpm004+nZcrPE17Ztxp08IdJ+1nD05XIdFC48TWswYmC4KJxh9i5/W8mfw++lPzuqfNcUbpJYyXeilki3FAPRevmxUlbuwQPu5M2LqlT9hL8RIRIDoiY5RKDxxfN8ZvGSLlplRfKHbc1lMV/R9qMtAF9O27FNPGCr8RtmIi3NRAii5OEte7GNxLhT0vqnZkqtx7Px/TUtTURcrrBM8w5YoZvtEy6Shik5Q6dIT6JOWLJfE0q/6dJem4TfSoSTyZpfya/SN3U8BkRP5qJ3w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HFFg+KXFaOGgOEs2RZCfxcvFp107cZ4gbpnoS/YcXQ21eM6mBvdHG8uEbPcIz3O4QHmlm/iapD95flqd59K7wF9L0qUOjaWNFx7HOHw1lT8a/A7FTR5eKHfcjiX+CxuXaaHXiFjfZhEf6RKW/0XiRb+9xU60E+vEFzqzHXpo+XRsEEuBcw3EXNaKuMlFog93Zeo7T2yo3Dp6IjfEHHwkaf8u9T/Ne9ihQf1KNxEjXiQ+Nrg3uf+gWKadib8bOM+6BZ/AB0R4ZK04znK+OOmwWXxFVMNo8VuPm7y8UO64HWv8FzIu0x7oNfiZ2EFbJA6wHiGWmjPVP2JQFNbhLwbOSRIzy0Yx28w2ONZS+x78ukz+JLHLt0HsQBeNk5N0vIiBfqjONTfzTKWbwA3Ce9gglodXiS9Y9uLzmbJXixjXg4lsi8V4XypenPRO62jxm+UmLy+UP24ZW/wXMi67xtA/0i8RB2/PMBBjyYN3iy9JZqg/y1doHZVuGqPipjyMOvdjyYAeid+LP1F9bc46JopZZwve2Ca5KlS6GQoVN+Vh1LnvxP+ebIQnxCHzrfL/OWq3+D/B7FcjFUaGSjeNUXFTHkad+7HkgVaoUKFCR2EseaAVKlSo0FGoDGiFChUq5MT/AIu8wK5Qkm6DAAAAAElFTkSuQmCC\n",
      "text/latex": [
       "$\\displaystyle \\sin^{4}{\\left(x \\right)} - 2 \\sin^{2}{\\left(x \\right)} \\cos^{2}{\\left(x \\right)} + \\cos^{4}{\\left(x \\right)}$"
      ],
      "text/plain": [
       "   4           2       2         4   \n",
       "sin (x) - 2⋅sin (x)⋅cos (x) + cos (x)"
      ]
     },
     "execution_count": 94,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "e1=sin(x)**4 - 2*cos(x)**2*sin(x)**2 + cos(x)**4\n",
    "e1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 95,
   "id": "f66c4d10",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAJ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P7UIcNgabZ16qkInaBjVwWNxuviauczeghWjX8bcZGjP8DGH+0IIPGLQ4AAAAASUVORK5CYII=\n",
      "text/latex": [
       "$\\displaystyle \\frac{\\cos{\\left(4 x \\right)}}{2} + \\frac{1}{2}$"
      ],
      "text/plain": [
       "cos(4⋅x)   1\n",
       "──────── + ─\n",
       "   2       2"
      ]
     },
     "execution_count": 95,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "trigsimp(e1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 96,
   "id": "fd8b0401",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAALkAAAAVCAYAAAAac0/JAAAGfklEQVR4nO2beWxVRRTGf2UTREUE0YiBF0JADBGC4JLIKmBREahGY2KFCogQBENCBCOxREUTRcStKNEoikGlKliEurAKbhiLiYI7CggKSsENFa1/fHPT6fTe9+577777Gu2XvMzt3Jkz55w5Z+bMudOC0tJSGtGI/zKaZNAnAdQAT0bIxxLgB6B1FjTORnyNj4Sj3OL/Jm8q5FQfmRh51OgLXAPcDfyaBZ0PgJeBO4DjfN4niN45M0Fc8to4BfgbeCCL8XKFnOsjEyPfA/QAZmfBkI15wGGgLAJadwGnAtMioJUr5EPeUWiuX4pgzKiRc31kYuR/ATuAvREw1Q0YCjwP/B4BvfcQb5OAphHQixr5kncM8COwMYIxo0Qs+nCN/DLgTWTAfwDfARuAKVabBPW3fbsuASwDDgBHgK3ApQFMXQcUAM8FvH/N0C1y6gvMWDVom7OxDOiElOehFPjaPI81/bzfOFM/DigHvkIKPwxsRlupHxKkL3Nc8tpoAwwBXkEhi4cwc+3hXGA5sA/4E9gFPAqcFjDmOUjGPYb2XiPblU67WPRhG/n1wArgTKSQ+cCrQCugJIAJF52RNyWApw3zPQ3dwT7thyLFvxNAbybwD4qz7JXqXmSsi4FZTp/Nphxm1a0HFprnbcBc61dl6ssM3xuB+5GyOhs5bg/gD9KTOS55bVwCtABetOrSmes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pcBnpt1KlPYqAV4wPO1BKcVClKq6KnMR6yBOeUejQ9r3Pn3CzvUO9MHmCbSarkF6a44Wi/7I+LyV9RMU5y8CPjQ8fY52lL7Az9T9dhCLPuyVfBbwNtDHMFpihLnZMOaXbsoW5WgSrrXquqK4sAYJ76b2vDsz9/jQa4MmtwJlN1wUo0NYIXAbSnX1AT5CMm5BW+Rk4AS0Gi5KT6SkiEvefmjVDApV0pnrZ9ANv6UoZJiKvgJ3RUbnfuBZjFbhCrQzzkRfVw+g7JWNWPRR0ADuk89Gl3T6IO/PBjeim3YD8PfyhoA45J1nxulC7XWGhoqc66MhGHlL4FO0mo7Mgk4r5PVbgCsi4CtXiEPe7ejOSO8s6MeFnOvD7/ARN46gMGIw+tSb6Z3iBPAY+b8vngpxyNsjQ5r5QM710RBW8kY0IqdoCP8Z1IhG5BT/AoLzUycqSyEsAAAAAElFTkSuQmCC\n",
      "text/latex": [
       "$\\displaystyle \\frac{\\sin{\\left(x \\right)} \\tan{\\left(x \\right)}}{\\sec{\\left(x \\right)}}$"
      ],
      "text/plain": [
       "sin(x)⋅tan(x)\n",
       "─────────────\n",
       "    sec(x)   "
      ]
     },
     "execution_count": 96,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "e2=sin(x)*tan(x)/sec(x)\n",
    "e2"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 97,
   "id": "c7e98ac8",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAEIAAAAYCAYAAABOQSt5AAADuUlEQVR4nO3Ya4hVVRQH8N9oQZNFpRkDgc4HyQrJHhZRKWOpRUVF0YcgR8zKiiiIIouCW/QQbLIHWBSRGcUUSkkSGRORPUmjiR72ocDsYaWYRQ+bpqYP6xzac+aee4c7TqPgHzbnzn+vs9faa6/HPtNUqVTsBaNGUPctWI9fsBUvYcpIGTOSjmjDMpyC09GLLowdCWMacUQr+rB8iLrPxJP4BB9jLsbj1BrvrMC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VORK5CYII=\n",
      "text/latex": [
       "$\\displaystyle \\sin^{2}{\\left(x \\right)}$"
      ],
      "text/plain": [
       "   2   \n",
       "sin (x)"
      ]
     },
     "execution_count": 97,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "trigsimp(e2)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "b9cb8c4e",
   "metadata": {},
   "source": [
    "* expand_trig，展开三角函数"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 98,
   "id": "f01a39cb",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAF0AAAAXCAYAAABpskPJAAAEPUlEQVR4nO3Ya4hVVRQH8N+oQaaQpUX0sIEkKyLFJCNKlNSkLCvoQ5KpWVn2sqTSMJmiF5QPMgiNyJTCQiNLIqMwyyzSygKxL9E7e4haUJla04d1Th3PnDv3OHObuZB/uOxh7b3XWfM/a//XOruhqanJAXQsurRhTyOasbiGcSzBj+hRQ5+djdMFT5PzE20hvdYYjCvwEH7t5FhqiQ/wIu5Dz+xEW0j/FidjZrvDCjyAX/B4jfzVEx7EUbg5a2wL6XvwKbbWIKgTMQLP4/ca+CuDieLYD+uAZ70vuJqCrqkxT/pFeEMQ+ge+w1pMzaxp1FLTs7ZGLMM27MJGjKkQ1FVowHMV5l9L/F6aszckz2oWstQRmJ48b3qF+f6Cs7dy9mXoK5IL+5J+LVbiFLyMOXgF3TGpZGDHi7fbiKWCzFMTv8ML1o/An3ivgr/b8ZfQxa4Z+yOYgCcwo2Rs7cW6ZDyzwvwCEeONOfs7yTgyNXTLTE7BbgwQnUQWfUoGNgxNuCdjexavCgLXZOw9MBBbVC6gH4uXNwHjRXbfhduEJF1XMq5a4EMhgUMK5i4TpD6KT3JzG5JxaGrIy8teodl5bCsZ2JciK7NYja9wRs5+jMiMarVhlpCpJpFF9yc+x4tT0FHYIwg8Dkdn7D0wVyTq7IJ9P4v4+6aGLOnP4BBsxjxcjCP2M7BNQi7y+BqH5Wy9k3FHFZ/fYL6QrgVYLzR+d4l4vhA6nP09lcytKZhbXMVfKhVZiZmNY3GnILgI22XUIisvc0VGTxUtzrQkkLVCGjZWCQh2VrDv1fJUpd3KwSX8/pT5ezJ+K7GHeFm9craBGIunxUvJYlMVfynpQ/ACTsKteDfxVwndZbqzbrnJJcmvF87CJaLDWC1687zWtwepr96truJyUTi/Fz3vLbi+5DPmF9gmCtIX482SflKsF4mYZvpjQiJvSOxF6CL4/DxrKMJO0blckwR3OM7ZzwCrYavI4P6trDlfZNBmnCZ63qtFhnUGdojCPxjjcC4W4qNW9vQXLe6m1JAlfbSWmQ9HJmPZI10WzaKn7YN+BfNnY7nQ9FHiBd2dxNhRvXkR1onat1DI8awq69NT8U/nliV9mfgHl4vjPEf03GPEPcLrNQl5X6xIxvNy9gFYJQrTSP92OMtFbRmr9ievLFJd7ymuQrZXWT9KNBcrU0OW9BmiIAwSxXQSDhJVebjiVrK9WIEfcGXG1k/UkGbxMj7L7UnvfB7+D+Ipg1SbN+DJKmsPFV3gKtHBgYY6uE+fKS69BmldG+sFL+ECIRsbqqy9SXwwDcXbqbEernbniY+nezs7kBIYhwvFjWg1wruLhFohQzjFhbOjsUt8XQ4XX3f1dqfeV5B9gpDBzbijxL5GLFLwwVUPpBNdTP52rl4wWtyL7xTFcJpyndwWcXXRAvVCej1jUfKrGepB0/93OEB6J+BvckPwXKxHEMIAAAAASUVORK5CYII=\n",
      "text/latex": [
       "$\\displaystyle \\sin{\\left(x + y \\right)}$"
      ],
      "text/plain": [
       "sin(x + y)"
      ]
     },
     "execution_count": 98,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "e1=sin(x+y)\n",
    "e1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 99,
   "id": "90945494",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAQQAAAAXCAYAAADtPTGLAAAHDklEQVR4nO3ce6xdRRUG8N8tGK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EacL+un8FbxUhHSbKtqL2Ft0zo2ZaMPG58p0cAj74Xfi5tjLhxhntvCQG/HqDHI1iV46nyLOp6/Qfb22jL1J59yYiTZsfK5UbWiMGveJm1THiNtkU/0/73F8Qt4f4GgKZZ3nCRI/WYSEW0Qu2g/j9h6dc2Mm2rDxuTIdIoQWsfm1Shw9fVtcULljD8qzN6K1YQa0DqFFixYPYjr8hFqLFi2mCVqH0KJFiwfxf6sQHxFsOlA+AAAAAElFTkSuQmCC\n",
      "text/latex": [
       "$\\displaystyle \\sin{\\left(x \\right)} \\cos{\\left(y \\right)} + \\sin{\\left(y \\right)} \\cos{\\left(x \\right)}$"
      ],
      "text/plain": [
       "sin(x)⋅cos(y) + sin(y)⋅cos(x)"
      ]
     },
     "execution_count": 99,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "expand_trig(e1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 100,
   "id": "d1bcdd54",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAEoAAAAVCAYAAADhCHhTAAAEDklEQVR4nO3YW4hWVRQH8N/oUIlBmT4Ihk4h2YNUVFQPXQyvSFQYIVGTpkJFZWFFGQlT2AUSumFK9mBFYeVQWpQWdNGMLlojVEqUmiaWSaZUimnTw9rH73jmfN83Q8M4D/3hsM5Z+7b2uu21T0NLS4v/UR99jrYAVfACdqJ/D697DtoxvdiQV1RT6rS4R0SqjnNxHR7Fnzn+QMzA6/ge+7AHH4uNdYfR1+ENzMXx+Ybe6FEPYy8WFPhXYxHOx2d4Aq0YiefwKhq6Yf1HMBgz88zepqjTMEZsel+h7TtcjpNxLWZjGk7HNlyFSd0gw+fYiBvRN2NmimrB5vQ+RYRg9kxN/KnCgpvSJvZijQiTMjSphHITlmAX9mMtLisZM014xSslbe/jTfxT4P+Mhel9VMm4d5McRSU2JNnaRZjnsQRDhdFAY6If4kTcjvUiTjO0JboA32IVdoicMREvYgTmlAgJw4SVNqW+J2EyliVBPsj1HYND+LTKXNXwd6IHS9ruxpci7yxL88M84RSLcG9hzJpEx2IlRypqi1BUm/CwIkbihwLvGLyTFlqI7SXjRqX5HsjxXsaKtIlMUf1xFjY4MonXQyOuT+8rStrXCwNNQbPwovswS4T4TSVjvkj04ozRlRxVVBIcwPwk7Ogq434U1sxjJbbivBxviMgJO7ogExE2I/F2mrcM94uQb8GteCj1bdYxlInTdL8IP3RNUUOFUjbiL5Uc1prah1QZ16bi7nlsw4Dc98BEd3dBppm4M8nUXKPfT+KUHIan8YnIWQdqjPkNg7KPxhod8zhV5JkBWC0S5B6hgCbh1sdWGft7Ff5BRxoqO+WO66RMt+BJkTdHi43Vwq+59+nC2LXQLydTpxU1S1j8Bh0L0muEov4rdiY6sGavwB14HF8LJe2s2TtknCdOyMEiF99co38fcbhtzjMyZOHRV0cMT7S1pO2SOkJ2FjuE1UfU6XePUFIbLlVfSRPxPL7BGSJMZ4j6qxpGiPKhLWPkFbVb5JyhOmJLoqMK/PFp0e5Auyg9BqkYpog5InmvE560q86cF2KpyFHjhCHmiEgq1k55XJDo4dIlH3p/iKvBRXhJVMKHsBzPiLB7TXjVdnHSTBBH7OQ6AncWraLCHi/uc3lMwYNJptUKV4yELSqp4Uy8JXLpWJXTdKkoeK8Qe11dMs+4tM6yjFHMUc3CrSeIuG4Q1lgs3HyucOVGUZ9MEsm6OxX1i6iL5hfaTkm0r8hRZfgoyTpcHP/tQunF0mY23sNjKt6T4QRcKZS8LWM29ML/UbPFxfhsfHUU1r8NT4li87C39bZLMeHRW0WY9TT6CUO1KoRkb1TUfpEC1ur5H3dNeBZ3FRs6W0f1NFalp6exQfk9t1d6VK/Ev3JJ8S0f6UHdAAAAAElFTkSuQmCC\n",
      "text/latex": [
       "$\\displaystyle \\tan{\\left(2 x \\right)}$"
      ],
      "text/plain": [
       "tan(2⋅x)"
      ]
     },
     "execution_count": 100,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "e2=tan(2*x)\n",
    "e2"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 101,
   "id": "531c74ff",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAE0AAAAlCAYAAAAHrmSHAAAEeElEQVR4nO3ZW4hWVRQH8N/YxUwj0u4XnaiXojJCe9A08yGLICoq7QZBSVRWFL5kFoNUEhaYmUQF2QXqwQzKypEuQtKFikknRuhCkqR5QVGii2n2sM7nnDl+M993vnN0mmn+sJnv7L3X3mvWXnutvfe/qaWlxQDyYVBvK1AAx2ATzsghswQPFJ24iNEexJfYiS14B+ek2ldiYYHxa2EWluPHHDJzMBtHF5m4iNEmYRHGYTJ24wMML6JQnTgS0/FiTrk1+Ak3F5m8iNGm4CV8i3bcguMwHotxMe7G3qQ0J3KX4RNsT8oKnJ0ad6VYjLnYis2Yl9H1CvyDVRmdrsNfGJWqexrfJ7rB27gx5//aBWXGtKOS8bbhPnwmjHpSUtYn/YZiPi4Uht2BZRicGusmYZRxuBf3Y2qq/SJ8LRYjjSViAWcn3zMxTSzUlqTuC4zFkAb/T4c2KlgF8/ENPsce7MLv+DXT783M960iLo7V6Tlr8VDy+zvcLkLA60ldMzZU0WGviHXvilg3K5FLx70NOAwnyxcP96EsT5uHiWJ77KnR93S8JhTeKTLgIIxM9VmdkfkFJ6S+j8Cf3Yy/QiSoR3E9vsq0/5H87VVPe0oE1kvwQx39l4nVvkMYYzc6cHiqz98Zmb26LvBWceSohskYnfTfXKW9kqi2VGmrC0U9bYFOg3Vk2nbhkEzdCBH0HxeZdq2IhXkXr03X5FHBaCzFXSLgP1alz7li0TblnHMfihhtkYhHN4jgf2JShiXt60Swb8axyVzbhZdMx5kiETwnvC0PWnFWMm4Fo/CeCBUv4xGR4SdkZCeK813DKGK0O4WXfIiNqTIzaX9SeFuH2AojRUacivPEUeVZPCyOCXnQLrLgtOR7uDDEMp3etUZk07kpuSG4Ci/knK8Lmvrw3XMKnhEeVyv5VDADV+LSIhP35btnq7imnZpDZhfuKTpxmee03sCCnP2fL2PSvuxpvYYBozWAyvbM3uEG0AMqRmvqVS36GPrT9jxNPCt1iLvrNQdqor6ePdPYLZ6kVuN48XS0XLy0lIr+5Gkbdb6ObBZXtvQ1qzROIW20ieKdf4NIDNfmGDwPVjqw3AGMEW9m61N1pXEKaaMNFSs1oyE1/zsYgVdwm85TQamcQtpo7wurLm1E0zqxWHXuoBZvQH3cwWC8lfT5NFVfKqdwsGNad9xBPbwBPXMHTWJRPsKrGblSOYWDnT13qM4d1MMb0DN3MF4YcI14/iEYsnYlcwqNelqLzu3VXZmUY7x6eAN65g5WJTLnp0p70lYqp9Copy3EGzX6/JxjvHp4A2pzB92hVE6hUaNtTUojyHIHFd5gBj5O6i4ooFs1tIktn0WaU7havPpenumzH6eQVmyYeLevoFm4+Db5vKYW1unkDn5Lxq/wButxisiKeXmDntCKJ8Rht7LYWU6hTfC2E0Qmr2A/TiHt2mMSwbbke17ye06JylOdOyiDN+gJpXIKfZkjyIvSOIX+dPeshdI4hf70ylEPSuEU/k+eVhoGjNYA/gUOMkfk3ljlrQAAAABJRU5ErkJggg==\n",
      "text/latex": [
       "$\\displaystyle \\frac{2 \\tan{\\left(x \\right)}}{1 - \\tan^{2}{\\left(x \\right)}}$"
      ],
      "text/plain": [
       "  2⋅tan(x) \n",
       "───────────\n",
       "       2   \n",
       "1 - tan (x)"
      ]
     },
     "execution_count": 101,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "expand_trig(e2)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "490a89df",
   "metadata": {},
   "source": [
    "## 3、幂函数运算简化"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "9170347d",
   "metadata": {},
   "source": [
    "* 看官方文档惊艳到我的一段话，完完全全就是常识，没有人引入复数或其他概念"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "b65b2fe2",
   "metadata": {},
   "source": [
    "![20210614-210933-0732.png](https://gitee.com/tsldsd/pictures/raw/master/img/20210614-210933-0732.png)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "2b5ea15b",
   "metadata": {},
   "source": [
    "* powsimp，指数运算"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "68656048",
   "metadata": {},
   "source": [
    "能合并1和2公式的，比如"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 102,
   "id": "4d84f414",
   "metadata": {},
   "outputs": [],
   "source": [
    "x, y = symbols('x y', positive=True)\n",
    "a, b = symbols('a b', real=True)\n",
    "z, t, c = symbols('z t c')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 103,
   "id": "e44546b6",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAC4AAAAYCAYAAACFms+HAAACJElEQVR4nO3XTYiNURgH8N8MytdOSqIsRpFiZkosWI4pFj42msUksaBoJPKRj0k0U6zspESywCxR42M7G4qhKYuhRKjJlEJIw+I517zduXdy553LTPkv3vO+5zzv//7vc87zf+6taW9vNxlR+68FjIIzuFducSILr0dvucWJLvxJucXxEH4CT/EJA7iE6Tk552I+hvAAX0T2VxcC8gqvwRTsxjK0oBn7cvI2pPEATqERb3EdUxUuOfATJzPPr3AbS3Ly1uM7NidOOCSyvgj9eTO+EOfxDIPiuGzH65y8DegyLBo+p7H29yWDuyKLW4rma3A5rXWmuTl4iHliS9diJb4Z6QaV8BIZf1wU24iPeFlK+EFREKfF2S3gHLbhIg6nuQ2iCLeiG31YhVklPrQS3plYjGlFX7ANV/GjlPDetLgUrWnuKPbjBnZlYj9gNjahDnvRIZOVMfIuFzvQmhJRl95dIFNPpc74MXxFO/aIDtadiIYycXdwAVfQI7J0TXjvzxy89XiR4m8Kq50hrHCwEFRT5rdKh+Gt60GT8NK8GDfecq4ykLnfMVbyavKWEt4iiuZ9em4bK3k1eYuFrxdntk8UyXPslL+hjDtvVvgaYfpvsE5s63HRXTtHvvrHqApvQfgK3BJW1oR3ab4Lj7BRNJhKUS1etcInu4WFNQsryuJIGs9WyF0tXsR29Yu2XQ73ReeqFNXixcT+IzEq/gv/25i0wn8BB2aUYg42ZigAAAAASUVORK5CYII=\n",
      "text/latex": [
       "$\\displaystyle x^{a} x^{b}$"
      ],
      "text/plain": [
       " a  b\n",
       "x ⋅x "
      ]
     },
     "execution_count": 103,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "e1=x**a*x**b\n",
    "e1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 104,
   "id": "ad924fff",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAADIAAAAYCAYAAAC4CK7hAAACRUlEQVR4nO3XTYiNURgH8N8do3ztpCZRFhQp7kyJhVmOKRY+Npo0IRYUjUSYfEyimWJlRUo0WWA2hBof29kQhpTFUCLUZEo+QsxYnHPH2537To17m7kz+df7nnue89xzzv885/k/92ZaWlpMBFSM9QZGgJO4mzY4nohk0Z02OJZELqJlBP5ZPEkbLAWRo3iKL+jFBUwpwbxJzMJs9OM+vgnRWZFzKJZIBpOwE4vRgHrsKXLefFTHdh+OowbvcAWVcq8iMIBjif5r3MLCIufNRxY/sT6uAQeEqMxDT7ERmYszeIY+4XptxZsCvs1xPPdsKmCrTVmnGh0JEvA1thWDrwTuCKe8Ic+eEZJzAG3RNhMPUCWEvBbL8ENhdTkrnGzuuVHA9jCFSBaP82w1+IRXDL1a+/EIJ3Adv6P9NDbjPA5G2xohqTdGgrAF0wssSohYX6L/OfZ7UjafwzQswOSELYMmtOMXQyPSHQcXoTHamrEXV7Ej4fsRM7AO87EbrRKnVCIsEQ6qEcvjWu2YI5GfhXLkML4LGr9LqKidcaL+hN9tnMMldAmndlnQ+gGlQxYv476uCVI/VZDewQhnUn5rtfp7hbpQJ2h32SJNtXoTn7cpcxIUJtIgJPeH2G8ave38O/KJrBbu/HMhyV5gu9IXuJIjSWSlUHTeYpVwvY4IEt029KvlhRyRpbgpSGcd3kd7h1Ck1kqvumWBCkGXOwXJrBekLolDsT01ivsaMSqFylo1jM89oZKWNcbTP8Rh8Z9IuWHCEPkD6Dl7l8u8rWoAAAAASUVORK5CYII=\n",
      "text/latex": [
       "$\\displaystyle x^{a + b}$"
      ],
      "text/plain": [
       " a + b\n",
       "x     "
      ]
     },
     "execution_count": 104,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "powsimp(e1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 105,
   "id": "59daba87",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAC0AAAAYCAYAAABurXSEAAACaElEQVR4nO3WW4hNURgH8N9hksy8eVEuL8RI8UI8IKVB5JKSKLd4IOQ6MnKZB0XxIENCRF4kKcUDeSHGw2iERLklcsm95FYuD2tNtuOcsWf2OUr5127t/e21/ue/v/P/vrVy9fX1/jV0KAHHRlzHe7zAQXQuJ29W0Tl0xCIMwAyMxfJy8lZkJP+OTYnnhziN6nLyZs10T+zEDbwW/sp5eFRO3nzRZ4WvnJoXz+FQfLc1xrqiCd2wGiMwBJ9xLbF2VVy3qojAfnHNhbS8+faoRTM24yS+xvh2zMF+rI2xCUJhTI+iYC4qcTXBeTGOw4qIbhD8uyQtb36mr+EI+mNWjK3DShzDwsTcV6jCFPTBUmzBO9xPzGvGRwwtIHgaarBb6BSpeHMF+nQP3MFzIcMNOINJ+JKYl8Ou+HGfcDS+H4xReZznMRLd8STGKnEbndA3ikrFW6h7PMYOwQYNaBQ8/iVv3ncsjtefcCmKHoYTMbZRSNC8hOBUvMW6x4vE/Xx8SCGsNVyKY4tFqrECl3G4rWSFRM8QbPEsPi9rK2kBNAoZbCnGXULxLfaz2FIjX/R44ctvYqDguQWybxZvcEvw5UyMxl6/dpnUSIoejuOCp8cIFtkg+H7r70vbjIvoIoh9ifXtJWoRPQinhIKowdMYP44rmCw0+Sxo8XUV6oSdrl3oIPTCM4K3xuJe3py6OG5r749EPIhjEw5kIarAXWHLLIZzQu/Milp8087iS6IU5+k0mImJ2CNkOhOyHk1bQy9BbG/MFjrSmlIQl1P0OOHM8FY4fC2XfZNCeUXvi1fJ8bc8XVL8F/238APEK5zuFs9OqgAAAABJRU5ErkJggg==\n",
      "text/latex": [
       "$\\displaystyle x^{a} y^{a}$"
      ],
      "text/plain": [
       " a  a\n",
       "x ⋅y "
      ]
     },
     "execution_count": 105,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "e2=x**a*y**a\n",
    "e2"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 106,
   "id": "8dacd3d8",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAADIAAAAYCAYAAAC4CK7hAAADaElEQVR4nO3XfaifYxgH8M9hf2y2oo6ysJMyNikvmbY/ULIXkWglbTkTU2hexpCJ4yQvp7wbyUReUmgTtSlaKXZGDmZ0mn+QlxobmyOvE8cf1/3k9nQ/v9/Zr1nIt57u330913Pf1/e6r+u6r19Xf3+//wL2apA/ia2YuIfsOA6jWNxCpw/v43tsw2MYX70sEZmBczGAH3aXpW3wDl7ALZhUeN+FvXEJjsQCzMPSSqFE5DZ8h4d2q6ntcTsm4/LCu1HchEF8inVYi+mVQp3I4ZiN5/DT32BsK7yFD3GR8H6OKbgfH2C7CK/z8XmlUCdygTjGZwsbvSI8M78m78Lj6d1Aki1L82UNRk/DL3itJn8GPcKZFboxJE7rapyI49P3m5qIzMZveLOw+TX4XcRx7rE7cR4ewXVJtj6NsxqIrEhrXFqTD6ZxTiY7XST1OXgZw5gpCtHGEpGJOAablZN8E57CEehNsutxlQjFizPdd0Voziysc3Yy9EFRhXIMpfGkTPaNKABnYSouE/k0go9LRA4SXtpS2LzCDfgZ/cKbtwov9YrTqvBrMmoKDszkE3G3KO19hfVH0vo9mewlPIwnsAGH4Wm8J8IXjMs+6E7jjhZEvsC9IoRWpIXnY2dBd1B4dhaeT7I+HCwSdaRhj+04IJuPYkl6GpGfSFWlxpcUM2zLfi/Gjw16VbxX4TUdV+IN4d0mTNBBxcyJbE1jd0kxYYFI7i/T/IoWuhuEN6uEf0CE7hJZSBTs2S+zZczIiWwR3p7WoHua8OQwjhI1/0LZpVTDDlE4ZmAhThGxvrFBX9q7S8T/LiEnMirq+v6iOuQ4AatEjswVhG8UOTagGeuxjyDwtSgWrVCd3qtjsP0vqN8jq9M4L5MdjTUiOef4s6qtwts4U1xSJVR5MgnLRSK3wlxxj73YzvA6SkS+wqI0nyrK66gg91FNf3ka72hY/5M0DuHRNrbsK+6KNbLWY6wYV5vvxH2icTxWxPPkFt+vEzHdhKobaJXgFRaJinlXG70iSt3vPfgMN3eyYIaFOEN00UNtdCeI012N1zvZrH4ixM3ai5PFTbwr/0l6BIFDhYeHce0YvjsEK0Xz2RFKRIjqVe9Mx4JTRR/0rUjYpZovzBybRdvTMZqIdIqV6dnjaPrP/q/D/0T+afgDbHq5dk4xcoEAAAAASUVORK5CYII=\n",
      "text/latex": [
       "$\\displaystyle \\left(x y\\right)^{a}$"
      ],
      "text/plain": [
       "     a\n",
       "(x⋅y) "
      ]
     },
     "execution_count": 106,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "powsimp(e2)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "5349f7ee",
   "metadata": {},
   "source": [
    "如果powsimp()无效，直接拒绝简化，比如："
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 107,
   "id": "f82a64a9",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAACcAAAAUCAYAAAAOTSQ2AAAB3klEQVR4nO3WS4iOURzH8c+MkSkjt61LWUloGkURZaGUlAUbyW2pbKRs3xRyXblFaVhIKGVhY6FR45Zh4bJgZacpJbdIZizOeet4OvPOeZ8pWfjV6bzvOc//d77POf//6eloNBr+VXXWiJmDfrzHd7zEuprrt/TKwe3DKLZm5ubiEWZhM5biFD7XABvXqysT1Bf7oczcBbzDJozEsTc1wIq8cnDL8AVvK+PzsR4rErO6KvJKj/WocJwL0YNf8f8otqE3jj0dZ+HBJC7XBkq90p0bwmXswAPcTeYGsCS+TA8+tfC8VYltahfm4R5+lnilcNcxI8L142Ll2W/4iPM4JLz5ajwUqqypE5l1jkewfhzEzBKvarU2i+F5ZoEP2Cjky+NotAXDmWeb6sBZ7McZ7BZyrMirWhB9wpa/GGOxQaxqAZNqEi5hO47hQLte6c51CXn1Gj8KAcbSZFyLYI0MWJHSnVuEbjybIFg3bmKDcJwn6xqlcL2xz+VbqabiNtZiD85NwOsPuNmxb3VNtNJ03BEu1p24Uh8rqHrPEUp7Mb7iFW4Uel3FSjzBAiHXqjqijXxO4e5jb9Km4HAhXCfWxN/LY6tqWB64CA5Ox9auRjCtRlxL1fme+2v6D1dXvwGx3nfcnOAsRAAAAABJRU5ErkJggg==\n",
      "text/latex": [
       "$\\displaystyle t^{c} z^{c}$"
      ],
      "text/plain": [
       " c  c\n",
       "t ⋅z "
      ]
     },
     "execution_count": 107,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "e3=t**c*z**c\n",
    "e3"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 108,
   "id": "c7dd5c24",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAACcAAAAUCAYAAAAOTSQ2AAAB3klEQVR4nO3WS4iOURzH8c+MkSkjt61LWUloGkURZaGUlAUbyW2pbKRs3xRyXblFaVhIKGVhY6FR45Zh4bJgZacpJbdIZizOeet4OvPOeZ8pWfjV6bzvOc//d77POf//6eloNBr+VXXWiJmDfrzHd7zEuprrt/TKwe3DKLZm5ubiEWZhM5biFD7XABvXqysT1Bf7oczcBbzDJozEsTc1wIq8cnDL8AVvK+PzsR4rErO6KvJKj/WocJwL0YNf8f8otqE3jj0dZ+HBJC7XBkq90p0bwmXswAPcTeYGsCS+TA8+tfC8VYltahfm4R5+lnilcNcxI8L142Ll2W/4iPM4JLz5ajwUqqypE5l1jkewfhzEzBKvarU2i+F5ZoEP2Cjky+NotAXDmWeb6sBZ7McZ7BZyrMirWhB9wpa/GGOxQaxqAZNqEi5hO47hQLte6c51CXn1Gj8KAcbSZFyLYI0MWJHSnVuEbjybIFg3bmKDcJwn6xqlcL2xz+VbqabiNtZiD85NwOsPuNmxb3VNtNJ03BEu1p24Uh8rqHrPEUp7Mb7iFW4Uel3FSjzBAiHXqjqijXxO4e5jb9Km4HAhXCfWxN/LY6tqWB64CA5Ox9auRjCtRlxL1fme+2v6D1dXvwGx3nfcnOAsRAAAAABJRU5ErkJggg==\n",
      "text/latex": [
       "$\\displaystyle t^{c} z^{c}$"
      ],
      "text/plain": [
       " c  c\n",
       "t ⋅z "
      ]
     },
     "execution_count": 108,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "powsimp(e3)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "f452e25e",
   "metadata": {},
   "source": [
    "如果认为没有问题，可以这样化简："
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 109,
   "id": "bcb87f91",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAACwAAAAWCAYAAAC7ZX7KAAAC6ElEQVR4nNXXXYiVVRQG4GfUcmQMQwUvSouIjEgxjYpCI9AKQgiqmzArvRBEg0SICGGIzH7UCLKiIKYuorTo5866CI2pGc0f0FI0iLoxDDPL0JSaLtb+6ps9+/zoJOQLh32+tdbe+/3Weffa63R0d3c7nzCigf0tHEbXOdhzFgawuEnMpejBjziJvZhHmfD1WIBn8HvmW5E2u38YhHfgQzyFsQX/ZPRhPO7FdKzHbzCqMOFp/IpXCr6ZtU2HgzXoxyNpvzpew/e4G38l24HKmWf4KszFRpwobDQLx3FwmIS3YT+WYGTNfhnuxKM1soOQE16EDryb2Z8VUrha/Ix/pucBIR/ordlKny3Zmu9gikhQhRlp7a/K7zlUEnPThL7MvgNv4kF8gU9rvorIB5m9wsOJ2GeZvTeN87A5fT8tkjhWyLIp4S7xhvsMPWwbcXEi3IPXC2utLdieT2R78GTm257GOTVbP37Bq1gtkjcbX4pKMUgSlwg9HSpszL8HblcDfx0deBkrsUFILdfkMVGyptRsRzBfaLk/Eb1PlFgMzvCENB5tQvg09rQgOxJvYCGew2NNYn/GpMzWi1saTahnuKoKnYW4UZiGb/BHEwIXiMO0EN0tyMIY5WrUEPUMV2mfUIi7RrzIziZrdeI93CWksK7F3iPEufiuHaIV6oQP4SdMLcTNSGMj/XbhY9yGpcqXTo6pQuu724j9B3VJDGArJuLKLK7KeqnUjMMnuBUPaY8s3JTGvNw1RV6H38c9uAPf1uzVVbwa14qy9zU24W3cLG6vK4R2c6wxVPu3i7L10ZkQ7sjaywvxg7jLb8xil2G5KDmjRQ+wSpSnUhNT4bChlWCc6MQ2i56hbeRX8ym8iBtwXeZ7SeiuU2jvCVFbL0rPjT45WaKKdGp9MFsShhdElvOb6b/CGDwu5Pf5mU4uET6JB0QDci4a+MtFC7nybCaX+mGiWmw9S0KtsE/5YLaFRn+R/rc47wj/DVrbm6+RO0ciAAAAAElFTkSuQmCC\n",
      "text/latex": [
       "$\\displaystyle \\left(t z\\right)^{c}$"
      ],
      "text/plain": [
       "     c\n",
       "(t⋅z) "
      ]
     },
     "execution_count": 109,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "powsimp(e3,force=true)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "346c2480",
   "metadata": {},
   "source": [
    "在幂是整数或有理数，sympy会自动应用，将它们展开，比如："
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 110,
   "id": "dd0c2336",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAACgAAAAWCAYAAACyjt6wAAAB7klEQVR4nO3WT4iNURjH8c+MEYWIjZWFlURpFEXkz8LCxk7J/x1loynZ3RRiTEmMhdKwkFCKskGiSDQosWGvKGUaC2HG4pxbp3fO/fPe9yYLv3o63fee8z2/+5znee/pqdVq/mX1lpx/FC8xhi+4i2UVPTRlljW4AcNYg034hQeYX8FgU2ZfSdiWwudd+Ia1wi/vRE2ZuQwexiR2tAGfI5zC1w7NtWTmDPbHcbQN2Fm8wfMuGMsyc0e8EuP40AI0iPVYh99dMjeFmWbwlHC0SzA7TpiMsbMAGsJubMbHzEZPk7W5eJxZk2WmGRzFFezBM9xPvkuB57AdG/E+sxHcLqyvax8W4VHheUNmavAG5kWDI7iU2WBYyOY2oYgXxufjMeo6k1k7GM2N4Fi7zGKT1BvkdWYDOCB02UN8SmKgwXzoiSYGcAH7MdEus9gk/fiJt002K6NpuCzU1mkcKctMM9iH5UIN/ChpJKfpuB7N1RqYa6k0g0sxE6+qOoucW9gqHNVQp6DU4Io4Nqq/djULd4SOPIiLVWCpwQVxHKvAm4t7WI29uFqBhanvQTguXHe+4x1uluBdE24lL7BYqL2iTipR46nBJziUxAycKGGwV/ibglUxivosb7otg3A+RieaEN5nXVXZC+tf13+DVfUHVTN6i+icYuEAAAAASUVORK5CYII=\n",
      "text/latex": [
       "$\\displaystyle t^{2} z^{2}$"
      ],
      "text/plain": [
       " 2  2\n",
       "t ⋅z "
      ]
     },
     "execution_count": 110,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "(z*t)**2"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 111,
   "id": "3e84c871",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAD0AAAAcCAYAAADSkrd6AAADaElEQVR4nO3YW6gWVRQH8N8pI0oLCqSMLnQhEyp7iOohX7paWEeECiXtoR4CAy2xMkpOUBR0IagIi6DLiUIMOtShKz6UGmEXtKweKl+ipCK1oMuROj2sPTh9zMyer4Y8Yn8Y5vvW3mvt9Z+19tprZmBoaMi+hv32tAN7AnsL6dMw3tU16T92/p9iuQjQeBfG+o30bPyuw6feYs1D8HPLua3QL+lFuBEDHV45XILX+/SzEf2QPjQ58EKXDrTABXizS4P9kL4Sa/Fjlw5ksD8OwK9dGu2H9DV4usvFW+BcrO/aaFvSJ2A6Xm2Y84YoNvN65AN4Ko3d26d/c/BKhXxZsresRm+6KLhvVw32kp6MaRXzFuF57GpwcDn+xF0iLQvcL7LkCdzaoF+FI7CtQr4u3c+p0Xs4+XBD1WBB+mRB6rvkZBkDgnQutTfhWczAwiS7DTdhNa7P6PdiBj6vGftQ7POzK8auwIV4FJurlAvSP+EBfIC5mFKaMwu/pIVyuB2/YUg85bvFcbNQZEGdD4dVyC/HyzU6u7ARx+CoknwyHhTBW1nnZEF6G97HMA72933ZTwH7Gg/hOJFiG5KtsZr5U8VDubNi7FR83LBWUeDKKb4SR+MW7KxT7N3Tq0UBuDr9Pyg5/VzD4r34vvT7WpEldZiG10RUy5jaY6cKBekixU8RjdO7MkHqJb0DozhfpM08vIdvMg4UmC9qQlF8lmTmbxYZcTjOKMnnJD+asEFU8CLSj4jitVimZa06soaTfL52BazApWnuFpwuitB1IgJNGBMpPliSzVJz3JSwHZ/hTCwQgVqFj3KOVpEeTQYX4yy8lDMimog1Yk9fJFLzDkzS7mwesZv0gfhD8/FYYJ2oQavwgyikWVSRHhN7+3i8KN8CzhQNxE5xVHyb5GtEcRwUkWvCqHhnPlZEbG0L39m9r6dghZYtcl1HNpzuz2T0TxKpOY6L8WXP+Ip0vy9jZ7uI2qB4qWnq/MrYmu4b8WRLHXUfEdaLgvRORv8LHNkw/pZ2r49Eis8VW2RHS52iC8wWrzLqIj2eDHb24t4CIzhPuyaIKF6X4TER6daYSJ+LtuIT9V0YsecX4ERxsmzBzf0uNJFIw1X4qmF8Nu4R6T+CpZqbn0pMNNKfZsYfT9e/wt7yCbhT/E96X8FfesbTpf6sBIoAAAAASUVORK5CYII=\n",
      "text/latex": [
       "$\\displaystyle \\sqrt{x} \\sqrt{y}$"
      ],
      "text/plain": [
       "√x⋅√y"
      ]
     },
     "execution_count": 111,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "sqrt(x*y)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "fe881fbd",
   "metadata": {},
   "source": [
    "* expand_power_exp、expand_power_base"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 112,
   "id": "abe73d3a",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAADIAAAAYCAYAAAC4CK7hAAACRUlEQVR4nO3XTYiNURgH8N8do3ztpCZRFhQp7kyJhVmOKRY+Npo0IRYUjUSYfEyimWJlRUo0WWA2hBof29kQhpTFUCLUZEo+QsxYnHPH2537To17m7kz+df7nnue89xzzv885/k/92ZaWlpMBFSM9QZGgJO4mzY4nohk0Z02OJZELqJlBP5ZPEkbLAWRo3iKL+jFBUwpwbxJzMJs9OM+vgnRWZFzKJZIBpOwE4vRgHrsKXLefFTHdh+OowbvcAWVcq8iMIBjif5r3MLCIufNRxY/sT6uAQeEqMxDT7ERmYszeIY+4XptxZsCvs1xPPdsKmCrTVmnGh0JEvA1thWDrwTuCKe8Ic+eEZJzAG3RNhMPUCWEvBbL8ENhdTkrnGzuuVHA9jCFSBaP82w1+IRXDL1a+/EIJ3Adv6P9NDbjPA5G2xohqTdGgrAF0wssSohYX6L/OfZ7UjafwzQswOSELYMmtOMXQyPSHQcXoTHamrEXV7Ej4fsRM7AO87EbrRKnVCIsEQ6qEcvjWu2YI5GfhXLkML4LGr9LqKidcaL+hN9tnMMldAmndlnQ+gGlQxYv476uCVI/VZDewQhnUn5rtfp7hbpQJ2h32SJNtXoTn7cpcxIUJtIgJPeH2G8ave38O/KJrBbu/HMhyV5gu9IXuJIjSWSlUHTeYpVwvY4IEt029KvlhRyRpbgpSGcd3kd7h1Ck1kqvumWBCkGXOwXJrBekLolDsT01ivsaMSqFylo1jM89oZKWNcbTP8Rh8Z9IuWHCEPkD6Dl7l8u8rWoAAAAASUVORK5CYII=\n",
      "text/latex": [
       "$\\displaystyle x^{a + b}$"
      ],
      "text/plain": [
       " a + b\n",
       "x     "
      ]
     },
     "execution_count": 112,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "e1=x**(a + b)\n",
    "e1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 113,
   "id": "85114fe5",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAC4AAAAYCAYAAACFms+HAAACJElEQVR4nO3XTYiNURgH8N8MytdOSqIsRpFiZkosWI4pFj42msUksaBoJPKRj0k0U6zspESywCxR42M7G4qhKYuhRKjJlEJIw+I517zduXdy553LTPkv3vO+5zzv//7vc87zf+6taW9vNxlR+68FjIIzuFducSILr0dvucWJLvxJucXxEH4CT/EJA7iE6Tk552I+hvAAX0T2VxcC8gqvwRTsxjK0oBn7cvI2pPEATqERb3EdUxUuOfATJzPPr3AbS3Ly1uM7NidOOCSyvgj9eTO+EOfxDIPiuGzH65y8DegyLBo+p7H29yWDuyKLW4rma3A5rXWmuTl4iHliS9diJb4Z6QaV8BIZf1wU24iPeFlK+EFREKfF2S3gHLbhIg6nuQ2iCLeiG31YhVklPrQS3plYjGlFX7ANV/GjlPDetLgUrWnuKPbjBnZlYj9gNjahDnvRIZOVMfIuFzvQmhJRl95dIFNPpc74MXxFO/aIDtadiIYycXdwAVfQI7J0TXjvzxy89XiR4m8Kq50hrHCwEFRT5rdKh+Gt60GT8NK8GDfecq4ykLnfMVbyavKWEt4iiuZ9em4bK3k1eYuFrxdntk8UyXPslL+hjDtvVvgaYfpvsE5s63HRXTtHvvrHqApvQfgK3BJW1oR3ab4Lj7BRNJhKUS1etcInu4WFNQsryuJIGs9WyF0tXsR29Yu2XQ73ReeqFNXixcT+IzEq/gv/25i0wn8BB2aUYg42ZigAAAAASUVORK5CYII=\n",
      "text/latex": [
       "$\\displaystyle x^{a} x^{b}$"
      ],
      "text/plain": [
       " a  b\n",
       "x ⋅x "
      ]
     },
     "execution_count": 113,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "expand_power_exp(e1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 114,
   "id": "f96e5db4",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAADIAAAAYCAYAAAC4CK7hAAADaElEQVR4nO3XfaifYxgH8M9hf2y2oo6ysJMyNikvmbY/ULIXkWglbTkTU2hexpCJ4yQvp7wbyUReUmgTtSlaKXZGDmZ0mn+QlxobmyOvE8cf1/3k9nQ/v9/Zr1nIt57u330913Pf1/e6r+u6r19Xf3+//wL2apA/ia2YuIfsOA6jWNxCpw/v43tsw2MYX70sEZmBczGAH3aXpW3wDl7ALZhUeN+FvXEJjsQCzMPSSqFE5DZ8h4d2q6ntcTsm4/LCu1HchEF8inVYi+mVQp3I4ZiN5/DT32BsK7yFD3GR8H6OKbgfH2C7CK/z8XmlUCdygTjGZwsbvSI8M78m78Lj6d1Aki1L82UNRk/DL3itJn8GPcKZFboxJE7rapyI49P3m5qIzMZveLOw+TX4XcRx7rE7cR4ewXVJtj6NsxqIrEhrXFqTD6ZxTiY7XST1OXgZw5gpCtHGEpGJOAablZN8E57CEehNsutxlQjFizPdd0Voziysc3Yy9EFRhXIMpfGkTPaNKABnYSouE/k0go9LRA4SXtpS2LzCDfgZ/cKbtwov9YrTqvBrMmoKDszkE3G3KO19hfVH0vo9mewlPIwnsAGH4Wm8J8IXjMs+6E7jjhZEvsC9IoRWpIXnY2dBd1B4dhaeT7I+HCwSdaRhj+04IJuPYkl6GpGfSFWlxpcUM2zLfi/Gjw16VbxX4TUdV+IN4d0mTNBBxcyJbE1jd0kxYYFI7i/T/IoWuhuEN6uEf0CE7hJZSBTs2S+zZczIiWwR3p7WoHua8OQwjhI1/0LZpVTDDlE4ZmAhThGxvrFBX9q7S8T/LiEnMirq+v6iOuQ4AatEjswVhG8UOTagGeuxjyDwtSgWrVCd3qtjsP0vqN8jq9M4L5MdjTUiOef4s6qtwts4U1xSJVR5MgnLRSK3wlxxj73YzvA6SkS+wqI0nyrK66gg91FNf3ka72hY/5M0DuHRNrbsK+6KNbLWY6wYV5vvxH2icTxWxPPkFt+vEzHdhKobaJXgFRaJinlXG70iSt3vPfgMN3eyYIaFOEN00UNtdCeI012N1zvZrH4ixM3ai5PFTbwr/0l6BIFDhYeHce0YvjsEK0Xz2RFKRIjqVe9Mx4JTRR/0rUjYpZovzBybRdvTMZqIdIqV6dnjaPrP/q/D/0T+afgDbHq5dk4xcoEAAAAASUVORK5CYII=\n",
      "text/latex": [
       "$\\displaystyle \\left(x y\\right)^{a}$"
      ],
      "text/plain": [
       "     a\n",
       "(x⋅y) "
      ]
     },
     "execution_count": 114,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "e2=(x*y)**a\n",
    "e2"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 115,
   "id": "9edb96a4",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAC0AAAAYCAYAAABurXSEAAACaElEQVR4nO3WW4hNURgH8N9hksy8eVEuL8RI8UI8IKVB5JKSKLd4IOQ6MnKZB0XxIENCRF4kKcUDeSHGw2iERLklcsm95FYuD2tNtuOcsWf2OUr5127t/e21/ue/v/P/vrVy9fX1/jV0KAHHRlzHe7zAQXQuJ29W0Tl0xCIMwAyMxfJy8lZkJP+OTYnnhziN6nLyZs10T+zEDbwW/sp5eFRO3nzRZ4WvnJoXz+FQfLc1xrqiCd2wGiMwBJ9xLbF2VVy3qojAfnHNhbS8+faoRTM24yS+xvh2zMF+rI2xCUJhTI+iYC4qcTXBeTGOw4qIbhD8uyQtb36mr+EI+mNWjK3DShzDwsTcV6jCFPTBUmzBO9xPzGvGRwwtIHgaarBb6BSpeHMF+nQP3MFzIcMNOINJ+JKYl8Ou+HGfcDS+H4xReZznMRLd8STGKnEbndA3ikrFW6h7PMYOwQYNaBQ8/iVv3ncsjtefcCmKHoYTMbZRSNC8hOBUvMW6x4vE/Xx8SCGsNVyKY4tFqrECl3G4rWSFRM8QbPEsPi9rK2kBNAoZbCnGXULxLfaz2FIjX/R44ctvYqDguQWybxZvcEvw5UyMxl6/dpnUSIoejuOCp8cIFtkg+H7r70vbjIvoIoh9ifXtJWoRPQinhIKowdMYP44rmCw0+Sxo8XUV6oSdrl3oIPTCM4K3xuJe3py6OG5r749EPIhjEw5kIarAXWHLLIZzQu/Milp8087iS6IU5+k0mImJ2CNkOhOyHk1bQy9BbG/MFjrSmlIQl1P0OOHM8FY4fC2XfZNCeUXvi1fJ8bc8XVL8F/238APEK5zuFs9OqgAAAABJRU5ErkJggg==\n",
      "text/latex": [
       "$\\displaystyle x^{a} y^{a}$"
      ],
      "text/plain": [
       " a  a\n",
       "x ⋅y "
      ]
     },
     "execution_count": 115,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "expand_power_base(e2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 116,
   "id": "21cfb9ac",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAACwAAAAWCAYAAAC7ZX7KAAAC6ElEQVR4nNXXXYiVVRQG4GfUcmQMQwUvSouIjEgxjYpCI9AKQgiqmzArvRBEg0SICGGIzH7UCLKiIKYuorTo5866CI2pGc0f0FI0iLoxDDPL0JSaLtb+6ps9+/zoJOQLh32+tdbe+/3Weffa63R0d3c7nzCigf0tHEbXOdhzFgawuEnMpejBjziJvZhHmfD1WIBn8HvmW5E2u38YhHfgQzyFsQX/ZPRhPO7FdKzHbzCqMOFp/IpXCr6ZtU2HgzXoxyNpvzpew/e4G38l24HKmWf4KszFRpwobDQLx3FwmIS3YT+WYGTNfhnuxKM1soOQE16EDryb2Z8VUrha/Ix/pucBIR/ordlKny3Zmu9gikhQhRlp7a/K7zlUEnPThL7MvgNv4kF8gU9rvorIB5m9wsOJ2GeZvTeN87A5fT8tkjhWyLIp4S7xhvsMPWwbcXEi3IPXC2utLdieT2R78GTm257GOTVbP37Bq1gtkjcbX4pKMUgSlwg9HSpszL8HblcDfx0deBkrsUFILdfkMVGyptRsRzBfaLk/Eb1PlFgMzvCENB5tQvg09rQgOxJvYCGew2NNYn/GpMzWi1saTahnuKoKnYW4UZiGb/BHEwIXiMO0EN0tyMIY5WrUEPUMV2mfUIi7RrzIziZrdeI93CWksK7F3iPEufiuHaIV6oQP4SdMLcTNSGMj/XbhY9yGpcqXTo6pQuu724j9B3VJDGArJuLKLK7KeqnUjMMnuBUPaY8s3JTGvNw1RV6H38c9uAPf1uzVVbwa14qy9zU24W3cLG6vK4R2c6wxVPu3i7L10ZkQ7sjaywvxg7jLb8xil2G5KDmjRQ+wSpSnUhNT4bChlWCc6MQ2i56hbeRX8ym8iBtwXeZ7SeiuU2jvCVFbL0rPjT45WaKKdGp9MFsShhdElvOb6b/CGDwu5Pf5mU4uET6JB0QDci4a+MtFC7nybCaX+mGiWmw9S0KtsE/5YLaFRn+R/rc47wj/DVrbm6+RO0ciAAAAAElFTkSuQmCC\n",
      "text/latex": [
       "$\\displaystyle \\left(t z\\right)^{c}$"
      ],
      "text/plain": [
       "     c\n",
       "(t⋅z) "
      ]
     },
     "execution_count": 116,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "e3=(z*t)**c\n",
    "e3"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 117,
   "id": "e9c81f9b",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAACwAAAAWCAYAAAC7ZX7KAAAC6ElEQVR4nNXXXYiVVRQG4GfUcmQMQwUvSouIjEgxjYpCI9AKQgiqmzArvRBEg0SICGGIzH7UCLKiIKYuorTo5866CI2pGc0f0FI0iLoxDDPL0JSaLtb+6ps9+/zoJOQLh32+tdbe+/3Weffa63R0d3c7nzCigf0tHEbXOdhzFgawuEnMpejBjziJvZhHmfD1WIBn8HvmW5E2u38YhHfgQzyFsQX/ZPRhPO7FdKzHbzCqMOFp/IpXCr6ZtU2HgzXoxyNpvzpew/e4G38l24HKmWf4KszFRpwobDQLx3FwmIS3YT+WYGTNfhnuxKM1soOQE16EDryb2Z8VUrha/Ix/pucBIR/ordlKny3Zmu9gikhQhRlp7a/K7zlUEnPThL7MvgNv4kF8gU9rvorIB5m9wsOJ2GeZvTeN87A5fT8tkjhWyLIp4S7xhvsMPWwbcXEi3IPXC2utLdieT2R78GTm257GOTVbP37Bq1gtkjcbX4pKMUgSlwg9HSpszL8HblcDfx0deBkrsUFILdfkMVGyptRsRzBfaLk/Eb1PlFgMzvCENB5tQvg09rQgOxJvYCGew2NNYn/GpMzWi1saTahnuKoKnYW4UZiGb/BHEwIXiMO0EN0tyMIY5WrUEPUMV2mfUIi7RrzIziZrdeI93CWksK7F3iPEufiuHaIV6oQP4SdMLcTNSGMj/XbhY9yGpcqXTo6pQuu724j9B3VJDGArJuLKLK7KeqnUjMMnuBUPaY8s3JTGvNw1RV6H38c9uAPf1uzVVbwa14qy9zU24W3cLG6vK4R2c6wxVPu3i7L10ZkQ7sjaywvxg7jLb8xil2G5KDmjRQ+wSpSnUhNT4bChlWCc6MQ2i56hbeRX8ym8iBtwXeZ7SeiuU2jvCVFbL0rPjT45WaKKdGp9MFsShhdElvOb6b/CGDwu5Pf5mU4uET6JB0QDci4a+MtFC7nybCaX+mGiWmw9S0KtsE/5YLaFRn+R/rc47wj/DVrbm6+RO0ciAAAAAElFTkSuQmCC\n",
      "text/latex": [
       "$\\displaystyle \\left(t z\\right)^{c}$"
      ],
      "text/plain": [
       "     c\n",
       "(t⋅z) "
      ]
     },
     "execution_count": 117,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "expand_power_base(e3)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 118,
   "id": "cd8e5b93",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAACcAAAAUCAYAAAAOTSQ2AAAB3klEQVR4nO3WS4iOURzH8c+MkSkjt61LWUloGkURZaGUlAUbyW2pbKRs3xRyXblFaVhIKGVhY6FR45Zh4bJgZacpJbdIZizOeet4OvPOeZ8pWfjV6bzvOc//d77POf//6eloNBr+VXXWiJmDfrzHd7zEuprrt/TKwe3DKLZm5ubiEWZhM5biFD7XABvXqysT1Bf7oczcBbzDJozEsTc1wIq8cnDL8AVvK+PzsR4rErO6KvJKj/WocJwL0YNf8f8otqE3jj0dZ+HBJC7XBkq90p0bwmXswAPcTeYGsCS+TA8+tfC8VYltahfm4R5+lnilcNcxI8L142Ll2W/4iPM4JLz5ajwUqqypE5l1jkewfhzEzBKvarU2i+F5ZoEP2Cjky+NotAXDmWeb6sBZ7McZ7BZyrMirWhB9wpa/GGOxQaxqAZNqEi5hO47hQLte6c51CXn1Gj8KAcbSZFyLYI0MWJHSnVuEbjybIFg3bmKDcJwn6xqlcL2xz+VbqabiNtZiD85NwOsPuNmxb3VNtNJ03BEu1p24Uh8rqHrPEUp7Mb7iFW4Uel3FSjzBAiHXqjqijXxO4e5jb9Km4HAhXCfWxN/LY6tqWB64CA5Ox9auRjCtRlxL1fme+2v6D1dXvwGx3nfcnOAsRAAAAABJRU5ErkJggg==\n",
      "text/latex": [
       "$\\displaystyle t^{c} z^{c}$"
      ],
      "text/plain": [
       " c  c\n",
       "t ⋅z "
      ]
     },
     "execution_count": 118,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "expand_power_base(e3,force=true)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "78277b45",
   "metadata": {},
   "source": [
    "* powdenest"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 119,
   "id": "c3968a33",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAADAAAAAaCAYAAADxNd/XAAADMUlEQVR4nO3XXYhVVRQH8N/YBE4GBVMkZeLDpEVQM1bUg/U0KuRD5YsIaaRBRR9GGH1QNojVgEalD6lB9EGQpVFggWlEhhJppIXoi0ElWYoTSpmJeXtY+9juzLmj995EBvrDufuetdfae//XXnutfdr6+voMZ4w40ws4BTyD9fU6hwOBbmyv1zlcCGyr11mPwBvYh1EtTr4A3+A37MerGJn1X4Ma5taxvxAX4zg+wWGxGzcUClUErsXt6MfvLSy+DWfhXlyJmZiKhzKdr/A+FuHcijF6UjsfCzERP2EV2usReBaH8HILiyc8+zQ24XtswIe4vKT3HEbjwYoxunEUt+Ez7MKjGItxDCYwHr14B3+0SOBSLMW3GBBhdCd+LOl9mRZ2t9ixHD1YLRxQoIiKESd+MswRW7+qYkEfC69OL8nb8Frq60+yTmwRnp2PG3Ed/lSdUd4WXu0tybvxdUk2EQfxXRWBXvyFLyomeUQcpkX+7akluAOv4LEkmyYO6wysww5cL5JCeUFEmMHkTHYOLsPZmawN8/AmjpUJjBKMd6o+vNuT4RWYlWRP4GERcvdkugfEobwVXXhAxPoJz5WwJbU3ZbKrxK7OEuS70vxjxNlSJnCJ8OzeigkKPIkj6MP9okquS5Mcz/Q+wgq8js3Ck2+JfF6rGPdgGndsJuvG7jTnuyIdd4gUOlAotWcGnan9dQgCe/CiCJVlaXHTRabIUcN96TlVDOCi7H15euC9ekb5DhRZZ2SVYob92f+5orj8F+jQRObLCexLbWeVYsJMcWh/Tu/zGp1wiHWcn62hIcMCe4V3J9TRvVnE9A5xwHbhLoMLUzOYIDLMtkYNcwI1bMQF4sTnmCQKyh5MEUSfEmeoX+so7jafNmpYrgNrUjs1k12NtSJTTPZPllqNrbhFFKpWMEXUnw8aNawi8Atmp/cukSZrgtTukv7jqV3c6MQZzhP1Yq3B14yTor30fhQviQtdj6iao4ew3yBitxXMFpnv+WaMq26jL+AHcX093egQu7gGnzczQBWBI6KybtX6B83JMA4rxYWvKZRDqMDG9Jxu7BTXkqYxHL6Jh8T/BM40/gZ2UKfcoHjkTgAAAABJRU5ErkJggg==\n",
      "text/latex": [
       "$\\displaystyle \\left(x^{a}\\right)^{b}$"
      ],
      "text/plain": [
       "    b\n",
       "⎛ a⎞ \n",
       "⎝x ⎠ "
      ]
     },
     "execution_count": 119,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "x=symbols('x')\n",
    "e1=(x**a)**b\n",
    "e1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 120,
   "id": "b5b260dc",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAADAAAAAaCAYAAADxNd/XAAADMUlEQVR4nO3XXYhVVRQH8N/YBE4GBVMkZeLDpEVQM1bUg/U0KuRD5YsIaaRBRR9GGH1QNojVgEalD6lB9EGQpVFggWlEhhJppIXoi0ElWYoTSpmJeXtY+9juzLmj995EBvrDufuetdfae//XXnutfdr6+voMZ4w40ws4BTyD9fU6hwOBbmyv1zlcCGyr11mPwBvYh1EtTr4A3+A37MerGJn1X4Ma5taxvxAX4zg+wWGxGzcUClUErsXt6MfvLSy+DWfhXlyJmZiKhzKdr/A+FuHcijF6UjsfCzERP2EV2usReBaH8HILiyc8+zQ24XtswIe4vKT3HEbjwYoxunEUt+Ez7MKjGItxDCYwHr14B3+0SOBSLMW3GBBhdCd+LOl9mRZ2t9ixHD1YLRxQoIiKESd+MswRW7+qYkEfC69OL8nb8Frq60+yTmwRnp2PG3Ed/lSdUd4WXu0tybvxdUk2EQfxXRWBXvyFLyomeUQcpkX+7akluAOv4LEkmyYO6wysww5cL5JCeUFEmMHkTHYOLsPZmawN8/AmjpUJjBKMd6o+vNuT4RWYlWRP4GERcvdkugfEobwVXXhAxPoJz5WwJbU3ZbKrxK7OEuS70vxjxNlSJnCJ8OzeigkKPIkj6MP9okquS5Mcz/Q+wgq8js3Ck2+JfF6rGPdgGndsJuvG7jTnuyIdd4gUOlAotWcGnan9dQgCe/CiCJVlaXHTRabIUcN96TlVDOCi7H15euC9ekb5DhRZZ2SVYob92f+5orj8F+jQRObLCexLbWeVYsJMcWh/Tu/zGp1wiHWcn62hIcMCe4V3J9TRvVnE9A5xwHbhLoMLUzOYIDLMtkYNcwI1bMQF4sTnmCQKyh5MEUSfEmeoX+so7jafNmpYrgNrUjs1k12NtSJTTPZPllqNrbhFFKpWMEXUnw8aNawi8Atmp/cukSZrgtTukv7jqV3c6MQZzhP1Yq3B14yTor30fhQviQtdj6iao4ew3yBitxXMFpnv+WaMq26jL+AHcX093egQu7gGnzczQBWBI6KybtX6B83JMA4rxYWvKZRDqMDG9Jxu7BTXkqYxHL6Jh8T/BM40/gZ2UKfcoHjkTgAAAABJRU5ErkJggg==\n",
      "text/latex": [
       "$\\displaystyle \\left(x^{a}\\right)^{b}$"
      ],
      "text/plain": [
       "    b\n",
       "⎛ a⎞ \n",
       "⎝x ⎠ "
      ]
     },
     "execution_count": 120,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "powdenest(e1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 121,
   "id": "39bb56e8",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAC8AAAAaCAYAAAAnkAWyAAADEUlEQVR4nO3XXYhWRRgH8N+7Zuy6hcEahVZIVAaCrFYmgUawFRGE0UUEJVkXYoJ2sRBF1CKVYokU9HkRfVBk2ScU9CkaimSR5YVdpFJBykYrRqVJ7XbxzKHTYY7re9ZQoT8Mc87MMzP/eeb5mGkNDAw4UdFxrAmMggfxYV3n8U6+F1/VdZ4I5LfVddaRfwGD6B7Dwvfha/yKn/AsOkv9F2EEt9eMPx2TMYyP8bs4hTmFQI78xbgZK/FbQ+ItjMNiTMdNuBp3lmS+wFt4AKdk5piZ6n4sxyz8iLU4qY78Q/gFTzYkTmj0fmzCd/gI7+LCitwKnImlmTl6cQjXYwO+wV04B1Nz5C9AH17FgTGQPxuPYTuGhOksxA8Vuc8SqUXipMqYiXVi8wUKS+jIkb9NHPnaDKFNQqN1ZUOS68FWodF+zMUl+EM+crwitNlXae/Fl5W2WdiPXSTbKaEPf2FLZpE35WPuwrT4+vR/rXDMG9Om4Fbh/FUyhFLgSryfvifgfIwvybWwDC/izyr5brHbHfKO+kim7eFE/DnhVPCzcMD5wmyuwT1KGqtga6rnldpmiI3fgk/SnAM4C9cVQmWzmSLsbk9mgSpaeEKYxePC3IZT33t4Gs9js9DgSyJej1QnSps6KJRQoBc7cS9eEyG3S4TJoUKorPmeVO8bhfg4EbMXYJWIAGWMYEkqR4ohnFH6fyoVeKNuUFnzRXTpzAkmjBcOtkAcY5V4U3RpEN3Kmh9MdU9OUGxqnXDIfqxud7EadOA07G53YJn8HpHGp2XkuvEOrsAdxpbAqpgmfGhbuwPLZjOCjZiE80rtE/EBLhch72gS55+7yvrDSmVQjfOv4wZxD/k2tb2My0Q2PFfYehUrRBJqgqtEbnm73YGtykvqZHwvUvKl4mT2y1+cCgz6d6RoBxOxVySn+e0Orl4PDuFRzBZ3i2GcKmyyrjQlTkStTg2dP3erXCO0vzzTdzTRhbuFqX7aZIIc+YMiLX9ubI+R0TAVz4iw2whVhy2wMZX/Ejvknf+Icby/YQ+L/8kfK/wNpCuhXGkFFfEAAAAASUVORK5CYII=\n",
      "text/latex": [
       "$\\displaystyle \\left(z^{a}\\right)^{b}$"
      ],
      "text/plain": [
       "    b\n",
       "⎛ a⎞ \n",
       "⎝z ⎠ "
      ]
     },
     "execution_count": 121,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "e2=(z**a)**b\n",
    "e2"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 123,
   "id": "0a444d24",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAB8AAAAYCAYAAAACqyaBAAABxElEQVR4nO3WTYjNURjH8c+9Y2oYspCahKSUUrozhUlRVpqmxEoWZOzYsFBK4qY05WWjkI28REQpxUbIggULb1uUlAWZUijSsHjOnY4790oz99+18NQ5p/M/p+d7nuc8v9O/VK1WtcvKBfs/hNvtglfwrJ3wp0XA9+M5PuMDzqArW5+NORjFHXwVWeifLLyEDmzHEmzCWuzK9vSmcTcOog/vcAVT1LoJ2E8cyOZvcBOLs28VfMeGtA57RPQL8HKikc/DcbzAiEj9EN5me3pxLQPDlzSWx7rMHoiomrX7mIXH6BEpXYVl+Ob3yq7gSZ3/PnzCa8an/brGuhzCfNzDoCisjelAsBXdGWwaFqEz81HCTlzAj0bwow3ARxL4rCicAUzHepH2AezNI8LSdLDNuIuPqGIu1tUc/+nOSzgpUnsC24RsbuE0zuFhivCi0HMtExW8wj5cFZKcKmQ2MgZo8rZ3CN1uwWFRpS23RpF34nICV4sCM/7Ou4Q8BkW6jxUFrod34wbWYAdOFQnO4TNFIa0QsjlfNDiHX8JKPMJCcdf1NiwekpbCy1id5stTq7f3TQ40afgoZrTa8d9Y0T8T/+H/HvwX/Kpg8NK0AgkAAAAASUVORK5CYII=\n",
      "text/latex": [
       "$\\displaystyle z^{a b}$"
      ],
      "text/plain": [
       " a⋅b\n",
       "z   "
      ]
     },
     "execution_count": 123,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "powdenest(e2,force=True)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "accab52f",
   "metadata": {},
   "source": [
    "## 四、指数和对数"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "d8adcacb",
   "metadata": {},
   "source": [
    "* 表示对数"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 143,
   "id": "bbcf9efc",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAA0AAAASCAYAAACAa1QyAAAA9klEQVR4nJ3SvyvFYRTH8dfl/gcGs90fcWWyGMiIgU1JGZRS30w2KcVguP+ADCIWEpNSBkkyyOImKZPBz+H7qNO3b/d++dTTOZ3nvE/n8/TUsizzV3WFvAfT2MEd3vCKM0zF3nqAxrCBRxzjAb0YwRaGUs93hG4xjD18hfoizjGaBmzH9Y6wWwCghc2UN4qe2uk9xY+qUB0TKT+oCq2gH/s4rALNYh43GP8ttoNmsIZrDOClEzSHdVwloBUvy6AFrOIyAU/FhiK0JDd+gUE8l60Rf8QklvGJU/kjFHWPZoT6UuyWeyrTCZpxvQy1DqdR5qmS/gX9ALg2MQ/Qmy4sAAAAAElFTkSuQmCC\n",
      "text/latex": [
       "$\\displaystyle 2$"
      ],
      "text/plain": [
       "2"
      ]
     },
     "execution_count": 143,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "log(9,3)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 148,
   "id": "6a4a0017",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAH0AAAAXCAYAAAAm70AZAAAFtElEQVR4nO3ad4yURRgG8N8dqFixxrNEKTYsCWKPSiwUGyq2RCOaYP/DXrEkaBR7jcbEFjRRQcGKomJvQY0t1qjBLnYFuwL6xzubXb+dzz04YC/Ck1xmd96pzzvzltlrGTlypIVYsNBa87kH/sbopqwkcAu+xpIdHGcTsZdDZrNfD83ngLnDQykHrfVtm4ZNcSAuwC8FWQuGYzJ+wq94FcegS2asl3EPzsVS/zHnypiJqzqw7rmN/+JhVzyCz/AbpuBObJUZp5SDzqT0UZiOazOym3EjemIsrseiuDJ9b8n0OR9t4mCUYQ/Bwd1zvOq5jzIeLsQE9MNDYu+viD08Jw5KEVkOOovS18EA3CFOcC32xDB8iA1wKI5FX3GS98bBmTFfxLs4Qt4awFB8h6c7sPa5iTIe2nASvsL6goPTsA8Gi0N/Tma8LAftVfp+gphpaTFvYAQWy7RtEUp5G7/jc1yN7vgo/RUxPPUbm5HtlcpL8W1N/V84K30+umTdY7CGILKI7tgB9wsT3x40i4c1ha5eEL6+Fk8Il7dSyZrrOGiP0kelRfTBbWnhLan+YSxSaH8NrhCbuw63YxAmZdpWMEAQPzkja0vllIysUtcPy2bkz6VyYEa2q3ARd5WsqYhm8vA+/sTmWLEg64+l8WjJmHUcdC1pWMFW4iR/mib8MtWPEH5wN5wsNg7b4ii8hy3wY6o/PS1qVXxcmGNJYarfUR+4UL3dPTOyXjWf11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fPic4TpzgJ0VE2oYdhVmdKH7/zeF3EY1vLx4eck+y7UUP4VNHF+r7dGDM2cVxmstDD3kO5ol531E8pPQVz6YzhDm7TZzyXGr1f0Sn5WFe3PTH0t+Cjk7LQ2f5J4qFmI9YqPQFEP8AhRbB08BLnikAAAAASUVORK5CYII=\n",
      "text/latex": [
       "$\\displaystyle \\frac{\\log{\\left(9 \\right)}}{\\log{\\left(8 \\right)}}$"
      ],
      "text/plain": [
       "log(9)\n",
       "──────\n",
       "log(8)"
      ]
     },
     "execution_count": 148,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "log(9,8)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 144,
   "id": "4617756a",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAA4AAAASCAYAAABrXO8xAAABAUlEQVR4nJ3SvytFcRjH8de92QhFSFmUUgYlG2WTxeIvsFiYlIXFWRSZGI1ksVgVFoNV3WRQBllImMRAGb7nW/ce5zrX/SxPz7fn3ffz/CglSaIZlTP5Fs7xgA+84grr6PoLXEYrTrGDQ3whQQUDsbAlA7bjM8fZBtawisW8H/MgOErjUD2r9TSbxkp8yFqNWkEbOjCOyRTabATsrcpPMI/nIqt9KKVxDoPCWsaKwKgnHGNa2ON+o2DUPW4wgu7/gNCfxu8sOCz0lFVZOIAeXOKN2qnOYBsXuMOLMNkpYTiPWIjF1eAZ9jCBUXTiHbc4wK5w9L/AaywV9Fnjvyk1Df4AlgcsqeBGdRQAAAAASUVORK5CYII=\n",
      "text/latex": [
       "$\\displaystyle 3$"
      ],
      "text/plain": [
       "3"
      ]
     },
     "execution_count": 144,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "log(8,2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 147,
   "id": "384520df",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAA0AAAASCAYAAACAa1QyAAAA9klEQVR4nJ3SvyvFYRTH8dfl/gcGs90fcWWyGMiIgU1JGZRS30w2KcVguP+ADCIWEpNSBkkyyOImKZPBz+H7qNO3b/d++dTTOZ3nvE/n8/TUsizzV3WFvAfT2MEd3vCKM0zF3nqAxrCBRxzjAb0YwRaGUs93hG4xjD18hfoizjGaBmzH9Y6wWwCghc2UN4qe2uk9xY+qUB0TKT+oCq2gH/s4rALNYh43GP8ttoNmsIZrDOClEzSHdVwloBUvy6AFrOIyAU/FhiK0JDd+gUE8l60Rf8QklvGJU/kjFHWPZoT6UuyWeyrTCZpxvQy1DqdR5qmS/gX9ALg2MQ/Qmy4sAAAAAElFTkSuQmCC\n",
      "text/latex": [
       "$\\displaystyle 2$"
      ],
      "text/plain": [
       "2"
      ]
     },
     "execution_count": 147,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "ln(100,10)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 124,
   "id": "2465744c",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAADsAAAAXCAYAAAC1Szf+AAADs0lEQVR4nOXXeYhXVRQH8M/MtJnRRBlNC2ZgWrQvfxhoC+kE/VP0R5DUCCqUEBkttBkMYZNoYStBUUwGZeWQQRBqq5VICxZWE1ORpDU10TLSIkPO9Me5j3m8eb95Q+PkgF94nN/ve8+995xz7znnvbrW1lb7Cupzv6dgAO17xZLAKvRg4ijWOEf4saA4UD9Ud6/hXFyNZfhzFOt8jLVYikPyA+PJ2TbsxON7YK370IQb8uR4cXYaZuNF/L0H1vsAX+JaNGTkSJ29EhvRm4zZijtwYIluHRbjC+zC93gUjdiWniLmp3kv1Nh/vcjDK0r2ak9jywpjqzFZBBEjc7YtGXEynkuG1yV+HfYv6D+GB4VzT+B5NGNDiW6G2diNzTXGb0W/yMOGHH8/5uFJ3F6Y836SczKiytnzxAlux2lYlDY+E6/igvQ/w6yk04VTRM7cglPFKR9TssfEtF6n2oXpUzwrAn5N4u7ETeLqX1cy58Mkz8+IKmfnJ7kUP+b4f3CziPbCHD8vyXvxe47vE0Erw7HitLorbFkiAtaK69Me64Tz/SX6vUl/ckZUOXt2km+WjHVhB07AYYk7K8n3SvQ3iyAVcUSSv1XYskOkx/F4BJtEDvcNM+dXTMr+VDnbmGStqHcX9DL5U4nubvxSwmfV96AKW+Dn3O8F+KtCf0Ju/Upne5NsqjF+dEFvZ5JHleg2GDzFPHqSLBvL4ypRkLJ0WlyhXy9uXE+eGA5bkrywZGwqjsO3BvMz059Zoj8D+5Xw3eLEpg9jx6V4Bp/jdNFDF+KkYeZMF13jk4yocvbpJJfgyBzfIKJcj6dy/Kok7zJ4peEA0arKMCB6+CQRwCJmYo3I2WYRmLtF4Iq9NY8ZSb6VEVXObsJy8ZHwmeihy0W0LhOFaEVO/x3RW6eJU3hIBGWryJ8flFfOjiQvKfBniBbXK/plViPW4KNkw6watjeLOvFKRozkpeI2kS9foUX0znpx2nMMrYaLRP/7Q/S/uXg96R5qMK/z6BBFrSXHTRWtZUAE4ZvCnKyVrTAUjbhcBGp7RuZzaJu442VYnZ6RoB8r05PHieIrpLNkTp+4BW2ifW3B12oXRiKAtextEdX9gTw5Fh8CTSXrHix6JLxcY95KfId7Rrn/BHHqHXg3P1BWHUeLG8W1f1vkWBMuFpX7NbxUY94u8TZ0kXiF/K/ftFNE3WgvDoyFsxtEYWnG4eKtqQsPi9MdGGbuxvSMBp3ilXIIxsLZN9Iz7jBePt7/F+xTzv4LnFHIHxn1Sz0AAAAASUVORK5CYII=\n",
      "text/latex": [
       "$\\displaystyle \\log{\\left(x \\right)}$"
      ],
      "text/plain": [
       "log(x)"
      ]
     },
     "execution_count": 124,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "ln(x)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 136,
   "id": "7245f0ff",
   "metadata": {},
   "outputs": [],
   "source": [
    "x, y = symbols('x y', positive=True)\n",
    "n = symbols('n', real=True)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "e2d19d01",
   "metadata": {},
   "source": [
    "* expand_log"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 128,
   "id": "d1ac9536",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAEYAAAAXCAYAAAC2/DnWAAAEbUlEQVR4nO3Ya4hVVRQH8J8zvXyQUUZTmRmZFr1LyEB7kE4RRBEUJKmgQkmRlpU9TIZQE63soURGYQZlpVQQRNnTzCQrKzPDCiUty8oXPcxS+7D2Yc7cOWfuSDr6wT8c1r1rr7P3Ov+99lrrnHYNDQ32oTlqcr+7Ywdm7hFPArOwDh3baL2zxTMPqxyoaW67x9Ab12IS/mijNT/ByxiPTvmBvYmYidiMx9p43ftQh5vyyr2FmJ7ojxfwVxuv/RG+xnWozZStJeZqzMcm4fhS3IkDC2zbYSS+whb8gGnojFXpqsTQdN/zJeu/IXLBlQVrzUxjk5JudPo/umSuXvg7PU+G2egmNgetI2ZicvgkPCsesl3Sv479K+yn4yFBxAw8h3rMK7DN0B/bsKhk/DZsF7mgNqe/H0PwBO5IugVJ9imZ69E0x4053QdJDsgU1Yg5V0TGapyKEcnJM/Aqzk//M/RLNitwsji3t+IUET1HFazRMc23XHnS/RzPiM0ZlHR34RZx/K7P2X4qovqcgnmuEg8/HV/k9IuTPC9TVCNmaJLj8VNO/68I1e0YntMPSXICNub0WwXBRTha7ODaKr6MFeQ2iN2eICJ2UPIjwz/iQY/RdCM64kHRDoyrmHtTmrtbpqhGzFlJvl0wtgJrcBwOSbozk1xQYL9IEFqJw5LcUMWXNeKIHiuOw0KRc7YW2GZHI3+cxqErxggiKrEeXbI/1YjpnGTZbq6tsMvkzwW22/BbgT6rQgdV8QV+yf0ehj9L7DJisuN0Im7Gh3i65J72OV+qEpMxW1cyfmSF3eYkjyiwrdUYHXmsS7JoLI9rRLLNjvTIFmwXisqURcy0tP4NSV+JGhH16/KKlrAkyQsKxnqI0FypMZ9k9n0L7PtgvwL9WhEJvVrw41Kx08twmug7hotIKMIGkcx7YyAuwuM5/yrRS1TazzJFNWKeSnIsDs/pa8Xu1eDJnH5WkndrPFZwgCjvRdgheoouguxK9MUckWPqBYn3CJInFdhnWIAOgpBf0zOUIYusdzJFNWIWYrJ4wfxSlLnJgtnL0+JTcvbvid6lp9jdhwWBS8UZ/lHTCpJhbpIXV+hPF23BJlFms5w2Bx8nH/qV+J7lmU6iIq4vf0z1Ige+kila0+CNEef7GwwWvUmN2IEBmleFEaK/+F30FwPxZrI9WGMeymOuSNiDc7oeohzvEIR9V3FPVv6nKMbKJBdrGtWV6IwrxAaszpT5M79KnLMizE5Xa7AdU9OVxwli95YX3LNVRNdEUfKX4FvlSZ8gu8xfGrvlsoSbYbCoiA/klbvjJbKuYN4OogeBl0rum4rvce8u8GEgLhNv6otbsGsvIm8u3s8PFFWJ/4tR4ui9K3JCnagKXfEaXiy5b4voYi8UXerOfpPpJgg5XkTBMtxe5Z7uIifOrBzYHcTME0mzHoeKbncFHhFR01JYz9f0rXdncIn4trJRJNFRyhvADMvFK0Yz7A5i3kpXW2NGunYJ9pYPVXsd9hFTgv8A8zf3WrWTX4gAAAAASUVORK5CYII=\n",
      "text/latex": [
       "$\\displaystyle \\log{\\left(x y \\right)}$"
      ],
      "text/plain": [
       "log(x⋅y)"
      ]
     },
     "execution_count": 128,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "e1=log(x*y)\n",
    "e1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 129,
   "id": "d28ad4e6",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAI0AAAAXCAYAAAA2o8yAAAAFVklEQVR4nO2afWhWVRzHP9t600mLZrTKbJG5ordlggZahrqgCCMoaOQLKpX04srKLJMRaqJRq5SoqJZBWbneCKIX0motab1YZsWilNRmVuqkF7N0/fE9l93de+49d8+e++yZPF8Y59k5v3PO736f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eO8fWXoFNfDDzp619p2rvpcq8Ah6Gy0oZOdDcwGJEXxBhgNYr5NYiYexBpwbsZP7zTtCZGJpdIm0sXjx6agYHIWH4z+sQhxKPLaFqApegl3NeoJFuKrG6SUWCZT/59dJ8wHHmFhxAhG1Bc/Bl7pdNk2osD/eegcrQDlYRePrAa+NToMDZC9xoU+19zPGOukAsuo3j0w8trBqEqbKdD7xCPSS735qJ84ntgCrovKEYWOpFw9TIL3Z/8ge5PaoF3jeyRdMVqP5pQwjfF1zcMldSdiIRgHuCVncsIowy4HBnclvjHyynS5tLGYxBebtJKd89mg5XHohz+nuZUVFquQsQFMQ+53RHEx9gkuAl4GF1IfdjLtfIRcVy6eHwduBSFnVbLuB9WHtN4YVlhWXcgXVXKKxHzHgR+Au7t5f4DEHFN9H+DyYTLOB5rgcvQG3CXwUTy6Cq5M0Edsv61KAepQFn6EOBN4KWIeXvR7e5F6JYy09+CVKJcoDHD+fmEOnrOZZDHcmQsp6CwtRG4I8HelUTwmEZ4Go/ekVQDR6Obyzb0gq4BXWcXkAzZ4PJaVCntRi8661ASnTFymdMUcJAgX36EVUA/QsFoCugx/gcfN5z7H5Y1GQAAAABJRU5ErkJggg==\n",
      "text/latex": [
       "$\\displaystyle \\log{\\left(x \\right)} + \\log{\\left(y \\right)}$"
      ],
      "text/plain": [
       "log(x) + log(y)"
      ]
     },
     "execution_count": 129,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "expand_log(e1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 131,
   "id": "fa467c99",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAE0AAAAXCAYAAABOHMIhAAAE10lEQVR4nO3Ye6zXcxgH8FfnuJSajKzckkkxdzLZKvejMcuxsWmqLW00pshdrJlibrlkhrFkI5TLMCPXJCaEJAuruUVINdeo/PF8vs637/l+z+841crmvX33/H7P5/nc3p/n8zzP99tu3Lhx/se/Q13udw+sxeRN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VdhkaRDz+5xBaU9xeKuLJpxgqaq86cULHa569Ror66WdRPw3Gi8l2W01xL4/pYpNDc7qeoqRYK8j8vNAnK2Hyh3aYCBktvWsuSnKOdW9JGTqLQ3hG1KpYN8YsFne3DFPT0xqswcT05LGXON0FJX1WCa+cIMqWufhMdQIiDqK43sYkWyIte7toKfhnGCqy+s155cZ4Ye9WMu42osaiekMT8QWuWY+5G8Xbw6KK9sEis96lqdKvQgfhzdPxer6hLJutL0aL6/yqiEHdRJbaVVToj1X0+11U90eLKr0t39T2KdF1F2TtKTxnPi5pxVg9RHyeXGzYGKTNEAG8AduLt4CF4kPgrVq+EjO1/TNOFQaK72LLRTAfrboozmOBeGVrho1B2kvp2VxwT3o2GDaXj5D/KfxPWhvwN3aEETnYMDowAAAAAElFTkSuQmCC\n",
      "text/latex": [
       "$\\displaystyle \\log{\\left(\\frac{x}{y} \\right)}$"
      ],
      "text/plain": [
       "   ⎛x⎞\n",
       "log⎜─⎟\n",
       "   ⎝y⎠"
      ]
     },
     "execution_count": 131,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "e2=log(x/y)\n",
    "e2"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 132,
   "id": "85602c2c",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAI0AAAAXCAYAAAA2o8yAAAAFOklEQVR4nO2aeWwVRRzHP331ghJrLMaqiDUi1XghkoAJeASoicZgTDSxEUiAqMSDKiqiSBoDSMAoKsSo0VQ0iEq9YmI84lkrsd6ImhqFyFFEBUo8EIX6x3c23e7O7mz73r6+R943eZnX2d/M/vbT38xvZvaVNTY2UlJJvVHG970G6AKa+sUTaSWwHajIoo9z0HNMz4lHvVcNBzjHTNi23zQKuBpYDPyZRT+fAS8DC4BB2btVdEqdYyEFzSJgN/BIDvq6F6gGbspBX8Wm1DkWStAMByYAzwN/56C/T4DvgWuB8hz0VyzKC8ekQXMl8AHQaZxZB8wFDrX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z0fnJH+j8pB5429geTneu9qsZLfim+OqGoS11F4IQXAd4286lhFUJXIYCblP84+VVabO0cQzKW5u00XNms8nKsSyPv6c5GW0tVyNwQc1F0+5I4nNsEt0IPIQOpD7Msq9CVBxLF8dXgUtQ2mmzXPfLyjGNF5bVln4HojMWgJci2j0A/Azck+X9ByBwzRR/wPSFZRzHeuBS9AbcFTCRHF1b7r6oAUX/e2gNUo1W6UOA14EXItrtQae7F6JTyr7+FqQGrQWa+ti+kNRA71kGOVahYDkJpa31wO0J7l1DBMc00tN49I5kBHAkOrlsRy/olqHj7JKSKRcsr0E7pV3oRWcDfT+gBPK7pinpAFGh/AirpCJSKWhK6rX+B220me5ZFAdFAAAAAElFTkSuQmCC\n",
      "text/latex": [
       "$\\displaystyle \\log{\\left(x \\right)} - \\log{\\left(y \\right)}$"
      ],
      "text/plain": [
       "log(x) - log(y)"
      ]
     },
     "execution_count": 132,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "expand_log(e2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 133,
   "id": "6697e625",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAEUAAAAaCAYAAADhVZELAAAEPElEQVR4nO3Ya4hVVRQH8N84vUxrogdOJWJgWvR+fLBS09IR+lIEBUZqqFBCaJSRlcEQZqKJZWVQVGZQVkpFQZjZw0okCw0tw4okLcvIGukhok4f1j7M6Xju3GvN1BT+YbO4a6+1zzr/vdfa69y65uZmB/BndPu3A+gk3I7V2IEf8ApOr9X5/0rKUMzHhbgEu/EGjq7FOU9KX7RiQUdGt59YiG3o8TfXGYknsR7rMBrH4aKczXnifccXnbvSSTkf12Imfu3gtY8Q77o9p/sIL2E6euaNuxIpM0QNeKQT1r4fa7GqoL8XjZiUV3YVUvpjOJ7H7x289mwMwVXYU5j7AJ/hetRnylpJuRor0CKCXicq/KEltnWYjE+xE9/gITRgUxpFjEt+z1V4/usi/68sedaCNDezxG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x^{2} \\right)}$"
      ],
      "text/plain": [
       "   ⎛ 2⎞\n",
       "log⎝x ⎠"
      ]
     },
     "execution_count": 133,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "e2=log(x**2)\n",
    "e2"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 134,
   "id": "a3f2c913",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAEcAAAAXCAYAAABZPlLoAAAEU0lEQVR4nO3Ye4hVVRQG8N9oVmZgpNFUYgqVRW8LKrBSspGCHiQFUSmolJKp9DJLYQgzyUJ7UfSiDMrKwaKoTLJ8JPaQjB7KUCRpadNzhFJMsz/WPs3hzLkz0x2l+cMPLuvetdc+Z59vr/XtdW5NfX29fShHt07MHYDdeHaPrKR6zEcTelU5/wzxHGOLA3ly+mAcFuFrbEMzVqaJnSFyb+FMXIvZ+KPKa6zBq5iJg/MD+Qe+Ek/iLHyIeWjASXgKL6OmygXsLczCVjzWyevci1pMyjvz5DTiUvTDNZiGMTgeGzESV3RyEXsSx2G42LRtnbzWR1iPG9A9c+bJWYrX8Xdh4hY8nr4P/Q83vArLRWluw+eC8ANKYmswGV9hO77HI+iNDelTxJg076UK939HaElxQ2uETu4W5ZhhAfoLwtFxHfkr2Z0djJ8lFn0CXhAPWpP8i9GjEP+oKOPeeAIvog5LSmIzDMcurK4wfpvY6Jly2YD7MVpIyB05/wfJXpg5OkLOfhiVvr/dgfhzRIZsxMmYkBZ6Gt7A+el3hnNTTCNOFHV/q9C67Tiy5B690vXWqSzEn+F5sUHXJd+duFmU4vhC/MfJnpc5OkLO7LTQN8Wut4cxyc4UJZlhJ24Ruzku5x+d7D34PeffIUguw1EiGza3s5bpguB6TEz3WCzIKspHc4rtnznaI2eSeKD1WthvD4OTXVoy1ohNGIhDku/0ZFeWxK9WXsp9kv2tnbVsEuV6NB7GKqFBOyrE/4q+2Y+2yLkRDwqRHJYmdgS9k620q5sLcZn9sSR2F34p8Wen04EdWM9Pue9j8WcbsT1z165IzhQhol8IYrZUiCtDc7K1FcaPKMRtTfbwktjuWrIkj6Zky8byuFoIcLb+yW3EdhPZ3JR3FDEVc7FWENNUEtMWPk12aMnYMaKP+laLvmTxQ0rizxYHQhGbRUYMamMdF+M5fIlThDSME31bGQaJE3Vt5iiSM0MI8BpcgJ/buHklPJPsdByW83cXu9gNT+f885O9S0uJwf7i6C/DbtFD9RWEFzEEC4Xm1AkiZwiiZ5fEExsB72WO/K6Mxt2izlcotNIJG7T/orkK9+F2UZYLxXF7kTj1VmJOLn6Z6G2uF7vcIPqqS0Tp/aD1ySLFjcQI8S6Y4VTRMjSLniXTuIX4BJeJ9mFF4Xp14tlfyxx5cgYm211oThmW6dhb+FRRLhNFj9QD34hsekDr02KClvZ9vBDhRaIv2ZTmFtEgRHyUaCKJLFosMmtEybxporGcoyVTiIy9XJC6MXPWdPH/c44Vx/8CIa5FTBOlN1iLdlWDm/CQaAD/zaiu8jdErdZrOUj0KEQWlWEuvhNyUC16CpIbFEqt7CT4PzBFZMb7QiNqxYHQD2/hlQrztovmdJh4pajmP50BQvOeLQ50FXKWCCGtw6GiK24UqT5PaEglLE+farFOvF60Qlch59306VLoKprTJbGPnDbwDxZF91/5xXFjAAAAAElFTkSuQmCC\n",
      "text/latex": [
       "$\\displaystyle 2 \\log{\\left(x \\right)}$"
      ],
      "text/plain": [
       "2⋅log(x)"
      ]
     },
     "execution_count": 134,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "expand_log(e2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 138,
   "id": "68ab2dd9",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAEUAAAAYCAYAAACsnTAAAAAEKklEQVR4nO3Ya4hVVRQH8J8zPTQlI42mB2ZhWlROVh8MtKdO0JeiD1FRCiqUENmTXgZDmIkW9kQoCjMoS4cKhDDtZWXSgwwrY1SSsqaMHmNW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ovqSXiFoMXWN8o4itMixMVy3YibnpyuNEUW2W1Qrbxa6aqbPyXK9ygieErjTfWjFBnHr5r+ce+SBsKBn3EFFjwEsV+s3F17i3B+ZUhn5it7XgnXxD2WnQXdwowu0tkQMacKE4qV7Fogr9tonq9HxR+nf3P5VqGCry3/xiQ0+IskwkyCYcLqrIVjwidkvHbvquSNd/gbXik2EX9IQor6frf4ve8idTr8J+UUqwX5QS/AOxJOMhjqK9NAAAAABJRU5ErkJggg==\n",
      "text/latex": [
       "$\\displaystyle \\log{\\left(x^{n} \\right)}$"
      ],
      "text/plain": [
       "   ⎛ n⎞\n",
       "log⎝x ⎠"
      ]
     },
     "execution_count": 138,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "e3=log(x**n)\n",
    "e3"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 139,
   "id": "dee3344b",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAEcAAAAXCAYAAABZPlLoAAAEU0lEQVR4nO3Ya6hVVRAH8J/eykxNKavbA7PwkWTlI0hJe5AaFGT4IShKSYUSIqP3w0DCVLQwywiKwgzKSnsRhdlLK5HMrLQMJZK0TKNSsRJJ7cOsjdt917navUFX8A+buWdm1jpz/mtm1uzbauLEiQ4hj9bNWNsVezD7P4mk6ZiDzWjXxPX9xe8YUzU0h5yWgHNxLabijybusRyvYRLalw0HOzmTsQ1PNHOfKajHzWXlwUxODwzBS/irmXt9im9xA+oKZZWcoaL+pqA3nscmbMcSnPcvvvAqLMZWEfxK3IM2Gd9WGI9vsAM/YhY6Yl16qhid1r2Ysb2TfseIzPfMTrapFdtcdBGEoyE5fZPsgWWiBp/FIgzEG+iQCaaKySnoXoLgWSmwyViAwyv+j+MRQcaTeAHDsDDjW2AIdmFpxnYHdos+UlfSP4RReAp3V9Z8kuTQQlElp1+Sg3E+rsCduByv4Hj0qRFsgYEiQ9bjLIxLwfbBm7gwfS4wOPmswZmi7m8XmbsDJ2W+o13ab7V8I/4Sz4nDuS7p7sWtogxvzKxZluQFhaJW5lyPzyu21Ukemdm4jNFJTsLPJf3fuE2c6NiSflSSD2JLSb9TkJzDySIjNjYSxwRB7kTclPZfIMjanfHfmvy7FIoyOe3RDT/grczi05P8rpGA2Jt972dsa7ABp6FT0hUH8nHGf6kgtYpjk/y9kTg2iFI9FY+JnjlCkF4Lv6Fz8aFMTp/0uWhmVfQT7H7fyOZE36D2qW6s+BVyU8Z3F37N6IvbaX9Z/Evp7zH4cz/+bUt770NOceLLM4s6oDtWyBNXxtYk62vYT6z4bUvyhIxvnb1ZUsbmJHO2AleLBlyU9vhGfAkuOpX23oecIr0/yyzsm3xzxFWxIsmLMrZuOEVk35aK/6CM/wAcltFvFFnRs0YMl4lb9mucLWaYsTijkbh7ihv1i0JRzZyd+CqzsH+S1SadwzNJTsBxJX2dOMnWeLqkn5PkffaWGBwhrv4c9ogZqrMgvIxBmCd6zjBB4v2C5OpsU8aAJD8oFAU5bcS1t0q+YRXkHEjmLME08WK6Ssww08SJDBeNd3rJf5GYbXqIk54pSFwpesBP8rfL/CQvLenOEePCVjGvFP1tnqiI4WJ0yGGY6HGvF4qCnN5i2MqVFEHOdqytYa/iLlHzazFSzC6tRTYN1fAAxokZZLuYQa7Bu8n3aHv7UhnzRRMfmT53E1f1HkFY9VYtxoLpGqIjrhTEri+URT0vF/VWC70yunX7WTM3PQeC3ZiRnjK6ixFjdYMVQfBMUXp9Re+qdQkQZNeKd6S4+R4uK1vKi2e9hrEcJeYUeLXGuhliLnugGd/dVmTVfHxUNuRugv8Dt4gy/FD0iXpcIm62t/FyjXU7xMR7sXilaMr/dLqKnje7amgp5CwUzXQYjhFT8Ro8KrKnsdlqcXqaitXiFaMBWgo576WnRaGl9JwWiUPkNIJ/AIdn6tEXss37AAAAAElFTkSuQmCC\n",
      "text/latex": [
       "$\\displaystyle n \\log{\\left(x \\right)}$"
      ],
      "text/plain": [
       "n⋅log(x)"
      ]
     },
     "execution_count": 139,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "expand_log(e3)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 141,
   "id": "a47745b5",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAEEAAAAXCAYAAABUICKvAAAEG0lEQVR4nO3YfayXYxgH8E/nJKXsGJnjZYkhM6ZkinmdyjLMxgyjiGlZXuZ1he1ovSAtLGyMnfrDEi3+MEveilpjYfOSRZO34hBqmpTKH9f9OM95ep7zO5ydlfHd7l2/33Vdz31f9/Xc1/e+fr9uTU1N/uuoy33ujx1o3iWRBOagBb27YO7BYn/XFA11O/vuMpyIK3AfNpXYbxGbuPwfzr8CL2Ay+uQNu1MSpmIjHq+wn5Dkik6sMQ2NuDGv3F2ScBSGYR5+q/AZjF/xWSfWeQefYizqM2VHk3AJlmCDCPJDTMCeJb7dcBM+wWZ8i1lowJo0ihiTnnu2xHa/KIOjxTHelr7vEOUDS3O6srE4N99c9BNJB92rdp3DVLHhH/GMeBsjk/4cDMfWnP+jGIe1eAJbcAFOwh4F3wzD0uaWl9hWYDZGYxkW5WzZ5hYU9BmuFht+I6dbmuRwLKR2Ek4WCfg6beK7pJ+QFj4Pt4uEwGkiAaswBL8k/US8ioPwZWGN3hiIlcoJcR72EUloxpMlPg+W6KaLBDRjUk7/bpKnZ4pa5TAmyclaEwB/4FZsx7U5/egkp2hNAHEaJlSscbCoz3XtxJGR4vs14iXK6jHcJk7lmBRnhg2iTPtlilpJyBZ/vcS2Ct/gMPGmYFCSb5f4LxfJK2K/JH+uEcdWwUXtoV68+XF4AOMFJxTxE/pmX2oloSHJqre0ruCXye9LfLdhfYk+uw16VqzRHccJov29MtLgm7kYhSbc2Y5vr9y6NZOwIcnGCvuBBb+NSR5Q4luv9a3n0ZJkmQ2OEQl6rzpMPQVHXSzK4N52fOvEyW3JK9pDVoNnltiOwCH4Qmv9Z/6nlvgPVU7E6/ADBlTEMLAwdxG98RLOxfWYUeGXYYDgjQ8yRa0kPJ3k3dg/p68XjFyHp3L6OUnepbU0oIfWG6SIHaIH6SsSW0R2QjaW2BrwCs7AVaq7zTyGJvnXtVnrilwmCOYOfITnxTU2EscKApye818seoPr8DHmC0I7X5TMWm2ZOsN8XCT6js8LtqxNnpLW3JTmfk70LaeITvBwwQVFTNOWS0YIfnoxU3TL/ZTuL472bJHVPC4VTHu8IKDVKYAZ4rrJo050jGPFzbFe1OtEcZus1nrEM/TAV6KHGFKykfG4AYeKLnUq7hGJ7VPin6FFW35qEFf9QlyYKfMnYY2olTLMTaMj2I6ZaeRxpAh4ZckzW/Cw2NwgO9f/rDSK2LuDMWUYJUi0DW90xQ+oxpJ598JD6fOCiudmitMwqcLeWfQSDdt8vJU3dOS3w9/FzbgMbwrmb8TZ4iZ5WdRyGTbjSpwlGL+she4M+gu+ai4auiIJiwR3jMC+oktchUfEaSjr4DIsSaMrsFI5cXZJEl5L41+D3eVPlV2K/5OAPwH04+mKRhu5ZwAAAABJRU5ErkJggg==\n",
      "text/latex": [
       "$\\displaystyle \\log{\\left(t z \\right)}$"
      ],
      "text/plain": [
       "log(t⋅z)"
      ]
     },
     "execution_count": 141,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "e4=log(z*t)\n",
    "e4"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 142,
   "id": "b14254fe",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAEEAAAAXCAYAAABUICKvAAAEG0lEQVR4nO3YfayXYxgH8E/nJKXsGJnjZYkhM6ZkinmdyjLMxgyjiGlZXuZ1he1ovSAtLGyMnfrDEi3+MEveilpjYfOSRZO34hBqmpTKH9f9OM95ep7zO5ydlfHd7l2/33Vdz31f9/Xc1/e+fr9uTU1N/uuoy33ujx1o3iWRBOagBb27YO7BYn/XFA11O/vuMpyIK3AfNpXYbxGbuPwfzr8CL2Ay+uQNu1MSpmIjHq+wn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9/FzbgMbwrmb8TZ4iZ5WdRyGTbjSpwlGL+she4M+gu+ai4auiIJiwR3jMC+oktchUfEaSjr4DIsSaMrsFI5cXZJEl5L41+D3eVPlV2K/5OAPwH04+mKRhu5ZwAAAABJRU5ErkJggg==\n",
      "text/latex": [
       "$\\displaystyle \\log{\\left(t z \\right)}$"
      ],
      "text/plain": [
       "log(t⋅z)"
      ]
     },
     "execution_count": 142,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "expand_log(e4)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "6d8e2195",
   "metadata": {},
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.10"
  },
  "widgets": {
   "application/vnd.jupyter.widget-state+json": {
    "state": {},
    "version_major": 2,
    "version_minor": 0
   }
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
